Routing for category tree

冷暖自知 提交于 2019-12-03 21:02:28

What you can do is accepting slashes in your routing parameters (for this route only). It involves that you can't queue any other parameter as slash separator will be seen as being part of category parameter...

So, how to manage slashes in a routing parameter :

_hello:
    pattern: /category/{category}
    defaults: { _controller: AcmeDemoBundle:Demo:category }
    requirements:
        category: ".+"

Calling /category/cat1/sub1/sub2 will call DemoController::categoryAction($category) method with 'cat1/sub1/sub2' as $category parameter. Just use your own code to decode !

Code sample found on official doc : http://symfony.com/doc/2.0/cookbook/routing/slash_in_parameter.html

ziiweb
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!