Note that there are some explanatory texts on larger screens.

plurals
  1. POZend router: combining a list of urls into a single or list
    primarykey
    data
    text
    <p>I have several urls:</p> <ul> <li>/dave </li> <li>/davina </li> <li>/dave/chris </li> <li>/davina/peter</li> </ul> <p>I have entries for all of them in my routes, an example of this is:</p> <pre><code>routes.dave.route = /dave routes.dave.defaults.module = default routes.dave.defaults.controller = person routes.rcp.defaults.action = index routes.davina.route = /dave/chris routes.davina.defaults.module = default routes.davina.defaults.controller = person routes.davina.defaults.action = index </code></pre> <p>I think you can see straight away that I have a duplication issue. Is there a way of combining multiple urls into a single route? </p> <p>I have played around with using /:person but I also have other content aswell not going to person controller.</p> <pre><code>routes.person.route = /:personname routes.person.defaults.module = default routes.person.defaults.controller = person routes.person.defaults.action = index routes.person.reqs.personname = "^[a-zA-Z0-9]+$" </code></pre> <p>Urls such as /search?person=dave which goes off to the search controller is obviously being killed by the expression above.</p> <p>Can I express the requirement as a list? "dave|davina|etc" or is there another magical zend method of doing this?</p> <p><strong>UPDATE:</strong> I was playing around and came across this partial solution:</p> <pre><code>routes.person.route = /:personname routes.person.defaults.module = default routes.person.defaults.controller = person routes.person.defaults.action = index routes.person.reqs.personname = "(dave|davina)" routes.person.route = /:person/:personname routes.person.defaults.module = default routes.person.defaults.controller = person routes.person.defaults.action = index routes.person.reqs.personname = "(chris|peter)" </code></pre> <p>I am going to run with this for the moment as is satisfies my requirements but I will leave this open(at least for a day) for anyone to offer there advice. The main issues is that both lists are going to grow, which will eventually cause an issue.</p>
    singulars
    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.
    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