在模板上检索当前页面,Symfony 2

时间:2013-01-25 09:31:58

标签: symfony

目前我正在使用:

$route=$app->getRequest()->get('_route');

基于我的routing.yml:

done_punctis_brand_stats:
    pattern: /brand/{id}/stats/{type}
    defaults: {_controller: DonePunctisBundle:Brand:stats, type: 'general'}
    requirements:
        _method: GET
        id: \d+ #digit [0-9]

因此,考虑到这一点,路线将回应: done_punctis_brand_stats

问题是,如果用户在/ brand / 1 / stats / general或/ brand / 1 / stats / othervalue,输出将始终 done_punctis_brand_stats ,我怎么能知道差异(在一个PHP模板)?

2 个答案:

答案 0 :(得分:1)

你的PHP模板中的{{ app.request.requesturi }}$route=$app->getRequest()->getRequestUri();

答案 1 :(得分:1)

尝试:

$app->getRequest()->getRequestUri();