Single Route/Action Definition and Exhibit Pages Hierarchy

Howdy! I am adding some custom routes to a plugin for a site that will maintain the exhibit pages hierarchy in the URL when viewing an item.

Instead of adding three routes to account for the heirarchy, I’d like to do this with one route if possible, so that these three urls would use the same controller and action:
exhibits/show/:page_slug_1/:page_slug_2/:page_slug_3/items/:item_id exhibits/show/:page_slug_1/:page_slug_2/items/:item_id exhibits/show/:page_slug_1/items/:item_id
From what I’ve found in the Zend docs, it looks like this should be possible with a regex style string for those three page segments, but I’m not having any luck getting it to work. When I break them out into three separate route definitions, it works; but I’d rather not do that if there’s a more efficient way.

You can do things like that with one route (Exhibit Builder itself does), but I assume the basic problem here is that your URL has the optional parts in the middle. There’s going to be problems matching that up when you omit some of the slugs: the “items” and “item_id” parts will sort of slot into the page_slug parts and the route won’t match.

Multiple routes can work as you said, or you could change your URL so the slug parts come at the end (or pass them in the query string, or there are various other options).

Thanks, John. I appreciate it.