=5.5.9", "components/jquery": "-6ren">
gpt4 book ai didi

php - 未知 "pagerfanta"函数

转载 作者:可可西里 更新时间:2023-11-01 00:29:15 26 4
gpt4 key购买 nike

我正在使用带有 Symfony 3.3.4 和 Bootstrap 3 的 Pagerfanta 包;

    "php": ">=5.5.9",
"components/jquery": "^3.2",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"incenteev/composer-parameter-handler": "^2.0",
"kriswallsmith/assetic": "^1.4",
"oyejorge/less.php": "v1.7.0.14",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^3.0.2",
"symfony/assetic-bundle": "^2.8",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.3.10",
"symfony/symfony": "3.3.*",
"twig/twig": "^1.0||^2.0",
"twitter/bootstrap": "^3.3",
"white-october/pagerfanta-bundle": "^1.0"

然后我的 AppBundle 中有一个模板,它扩展了 base.html.twig:

{% extends 'base.html.twig' %}

{% block body %}
<nav class="navbar navbar-inverse navbar-fixed-top">

...

    {% block content %}{% endblock %}

{% endblock %}

它又由页面模板扩展:

{% extends '@AppBundle/index.html.twig' %}

{% block submenu %}
<a href="{{ path('site_new') }}" class="btn btn-success"><i class="fa fa-plus"></i> Create</a>
{% endblock %}
{% block title %}
Manage Sites
{% endblock %}
{% block body %}

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

{% endblock %}

调用模板

    $adapter = new DoctrineORMAdapter($qb);
$pager = new Pagerfanta($adapter);
$pager->setMaxPerPage(20);
$pager->setCurrentPage(intval($this->getSessionPage()));

$data = $pager->getCurrentPageResults();
return $this->render('@AppBundle/site/index.html.twig', [
'pager' => $pager,
'data' => $data,
'order' => $order,
'form' => $form->createView()
]);

但是我得到了

Unknown "pagerfanta" function.

Exception: Twig_Error_Syntax

好像没有包含这个 Twig 函数,但我看不出还需要包含什么。 Pagerfanta 也在我的 AppKernel.php 中

最佳答案

看起来您忘记将 WhiteOctoberPagerfantaBundle 添加到 AppKernel.php 中,导致 PagerfantaExtension 未加载,因此{{ pagerfanta() }} 函数未定义。

$bundles = array(
// ...
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
);

关于php - 未知 "pagerfanta"函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45071543/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com