Zend Routing Dependant on DB Query?
I'm relatively new to the Zend Framework 开发者_开发问答but have Bootstrapped a routing configuration file and got the URLs /shop/category/:urlslug and /shop/product/:urlslug working fine.
My problem is that despite persuasion the client wants the URL in both case to be just /:urlslug
I had an idea in my head that the following actions might work:
- Route for /:urlslug - Matches go to a specific Rewrite controller - The Rewrite controller queries the category table, if found redirects to the category controller. If not it queries the product table, if found redirects to the product controller. If not triggers a 404.Is there a better 'Zend' way of doing this?
Thanks
You could create a custom Route (extending the Route base class) which does the url->parameters mapping based on a database (and not just the input string as the zend-classes do). Make sure to use very good caching for this though ;)
精彩评论