7

供应商文件夹
我正在尝试在不修改供应商的情况下将 twitter bootstrap css 样式应用于我的 knp 分页。
有没有办法配置 KnpPaginator 以检测现有的引导 css 样式表?因为如屏幕截图所示,它是为使用引导而构建的。

4

2 回答 2

22

@Derick F:非常感谢,我找到了另一种方法:
我刚刚替换了:

pagination: KnpPaginatorBundle:Pagination:sliding.html.twig

pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_v3_pagination.html.twig

它是 knp 包中包含的默认模板。

于 2014-04-12T20:28:56.157 回答
9

是的,在您config.yml和您的knp_paginator设置中:

knp_paginator:
    template:
         pagination: AcmeBundle:Common:paginator-bootstrap.html.twig

然后在paginator-bootstrap.html.twig

{% if pageCount > 1 %}
    <ul class="pagination">
    {% if first is defined and current != first %}
        <li class="first">
            <a href="{{ path(route, query|merge({(pageParameterName): first})) }}">
                &lt;&lt;
            </a>
        </li>
    {% endif %}

    {% if previous is defined %}
        <li class="previous">
            <a class="hidden-xs" href="{{ path(route, query|merge({(pageParameterName): previous})) }}">
                &lt;
            </a>
        </li>
    {% endif %}

    {% for page in pagesInRange %}
        {% if page != current %}
            <li class="page">
                <a href="{{ path(route, query|merge({(pageParameterName): page})) }}">
                    {{ page }}
                </a>
            </li>
        {% else %}
            <li class="current active">
                <a>
                    {{ page }} <span class="sr-only">(current)</span>
                </a>
            </li>
        {% endif %}
    {% endfor %}

    {% if next is defined %}
        <li class="next">
            <a class="hidden-xs" href="{{ path(route, query|merge({(pageParameterName): next})) }}">
                &gt;
            </a>
        </li>
    {% endif %}

    {% if last is defined and current != last %}
        <li class="last">
            <a href="{{ path(route, query|merge({(pageParameterName): last})) }}">
                &gt;&gt;
            </a>
        </li>
    {% endif %}
    </ul>
{% endif %}
于 2014-04-12T20:18:55.970 回答