开发者

Zend Routing Dependant on DB Query?

开发者 https://www.devze.com 2023-04-13 08:00 出处:网络
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.

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 ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号