Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Routing problems
    primarykey
    data
    text
    <p>I've read all posts about routing and Zend Documentation but I still can't solve this issue.</p> <p>I have a multi-language application with two modules: default and admin. The language selection is working fine (in a Controller routeShutdown Plugin), but I have some problems configuring the router:</p> <p>I want to have these URL working:</p> <pre><code>/ /controller /controller/action /action (default controller) /controller/param (default action) /admin /admin/admin-controller /admin/admin-controller/action </code></pre> <p>and using the language selector it would be:</p> <pre><code>/en /en/controller /en/controller/action /en/action (default controller) /en/controller/param (default action) /en/admin/admin-controller /en/admin/admin-controller/action </code></pre> <p>I added this to my bootstap file (index.php):</p> <pre><code>$frontController = Zend_Controller_Front::getInstance(); $router = $frontController-&gt;getRouter(); $router-&gt;removeDefaultRoutes(); $router-&gt;addRoute('langmodcontrolleraction', new Zend_Controller_Router_Route('/:lang/:module/:controller/:action', array('lang' =&gt; ':lang')) ); $router-&gt;addRoute('langmodcontroller', new Zend_Controller_Router_Route('/:lang/:module/:controller', array('lang' =&gt; ':lang', 'action' =&gt; 'index')) ); $router-&gt;addRoute('langmod', new Zend_Controller_Router_Route('/:lang/:module', array('lang' =&gt; ':lang', 'action' =&gt; 'index', 'controller' =&gt; 'index')) ); $router-&gt;addRoute('lang', new Zend_Controller_Router_Route('/:lang', array('lang' =&gt; ':lang', 'action' =&gt; 'index', 'controller' =&gt; 'index', 'module' =&gt; 'default')) ); $frontController-&gt;setControllerDirectory(array( 'default'=&gt;BASE_PATH.'app/modules/default/controllers', 'admin'=&gt;BASE_PATH.'app/modules/admin/controllers')); </code></pre> <p>In order to check how the router is parsing the URL, I added a var_dump to the routeShutdown plugin:</p> <p>Entering to <strong>/en</strong>, I get:</p> <pre><code>array 'lang' =&gt; string 'en' (length=2) 'action' =&gt; string 'index' (length=5) 'controller' =&gt; string 'index' (length=5) 'module' =&gt; string 'default' (length=7) </code></pre> <p>which is OK. But when I enter to <strong>/en/controller1</strong> I get:</p> <pre><code>array 'lang' =&gt; string 'en' (length=2) 'module' =&gt; string 'controller1' (length=8) 'action' =&gt; string 'index' (length=5) 'controller' =&gt; string 'index' (length=5) </code></pre> <p>It is setting module to "controller1". How can I tell the router to set the default value to the module? And for an URL like /en/controller/param? (setting module and action to default)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload