Note that there are some explanatory texts on larger screens.

plurals
  1. POZend reverse matching of routes returns current URL
    primarykey
    data
    text
    <p>I'm using Zend Framework, and am trying to set up some custom routes. These seem to be working fine during dispatch, but the reverse matching isn't working at all.</p> <p>These are the routes I've set up.</p> <pre><code>$router-&gt;addRoute('category', new Zend_Controller_Router_Route( 'categories/:category', array( 'controller' =&gt; 'category', 'action' =&gt; 'modify', ) )); $router-&gt;addRoute('categories', new Zend_Controller_Router_Route_Static( 'categories', array( 'controller' =&gt; 'category', 'action' =&gt; 'index' ) )); </code></pre> <p>If I now go to <a href="http://example.com/categories" rel="nofollow">http://example.com/categories</a>, the correct controller and action are executed (category.index). If I go to <a href="http://example.com/categories/5" rel="nofollow">http://example.com/categories/5</a>, I get the following error:</p> <pre><code>Fatal error: Uncaught exception 'Zend_Controller_Router_Exception' with message 'category is not specified' </code></pre> <p>Adding a default value to :category fixes this problem for reason (suggestions welcome). That is not the major problem though.</p> <p>Whenever my application executes <code>$this-&gt;url(...)</code>, the returned value is always the current URL. So, on <a href="http://example.com/categories" rel="nofollow">http://example.com/categories</a>, if I run </p> <pre><code>echo $this-&gt;url( array('controller' =&gt; 'category', 'action' =&gt; 'modify', 'category' =&gt; 5) ); </code></pre> <p>The returned value is <code>http://example.com/categories</code>. I am completely stumped..</p> <p>The problem persists even if I try to bypass the default router and do</p> <pre><code>$router-&gt;removeDefaultRoutes(); $router-&gt;addRoute('default', new Zend_Controller_Router_Route( '*', array('controller' =&gt; 'index', 'action' =&gt; 'index') )); </code></pre> <p>Does anyone with a bit more experience with Zend routing want to have a crack at this?</p> <p>Cheers, Jon</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.
 

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