【问题标题】:Symfony2 Pager FantaSymfony Pagerfanta
【发布时间】:2016-10-30 21:04:35
【问题描述】:

是否可以在 symfony2 中使用寻呼机 fanta 设置路由/渲染控制器,因为我尝试渲染控制器,但它却无法生成路由:

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "" as such route does not exist.") in @AppBundle\Survey\table_questions.html.twig at line 27.

在第 27 行我有

{{ pagerfanta(pager, 'twitter_bootstrap3') }}

【问题讨论】:

    标签: php symfony pagerfanta


    【解决方案1】:

    这样试试

    {{ pagerfanta(pager, 'twitter_bootstrap3', {'routeName': 'your_route_name'}) }}
    

    【讨论】:

      【解决方案2】:

      我不知道你如何使用WhiteOctoberPagerfantaBundle,但你可以设置你的默认视图:https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle#adding-views。另请参阅此答案:Customising the layout of Pagerfanta pagination with a custom template

      或者,pagerfanta 函数采用第三个参数和选项来创建路由生成器。 https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/blob/master/Twig/PagerfantaExtension.php#L100.

      值得注意的是routeName 可能足以满足您的需要:

      {{ pagerfanta(pager, 'twitter_bootstrap3', {routeName: 'route_name'}) }}
      

      【讨论】:

      • 实际上它只与 routeName 一起使用,因为我有页面的默认值。但你给了我更多我需要的信息:D
      猜你喜欢
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-17
      • 1970-01-01
      相关资源
      最近更新 更多