对于每10条记录,使用Symfony2和Twig打印一些内容

对于每10条记录,使用Symfony2和Twig打印一些内容,symfony,twig,Symfony,Twig,我正在构建一个页面,其中成员地址被打印到一张标签上,一旦一张标签上有14个地址,我想在它后面放一个分页符,这样地址就可以打印在多张纸上 如何使用细枝实现这一点 这是我当前的细枝代码: {% for row in data %} <div class="label-page"> <div class="label-section L7163"> <p>{{row.FirstName}} {{row.Surname}

我正在构建一个页面,其中成员地址被打印到一张标签上,一旦一张标签上有14个地址,我想在它后面放一个分页符,这样地址就可以打印在多张纸上

如何使用细枝实现这一点

这是我当前的细枝代码:

{% for row in data %}
    <div class="label-page">
        <div class="label-section L7163">
            <p>{{row.FirstName}} {{row.Surname}}</p>
            <p>{{row.AddressLine1}}</p>
            {% if row.AddressLine2 != NULL or row.AddressLine2 != '' %}
                <p>{{row.AddressLine2}}</p>
            {% endif %}
            {% if row.Town != NULL or row.Town != '' %}
                <p>{{row.Town}}</p>
            {% endif %}
            {% if row.County != NULL or row.County != '' %}
                <p>{{row.County}}</p>
            {% endif %}
            {% if row.Postcode != NULL or row.Postcode != '' %}
                <p>{{row.Postcode}}</p>
            {% endif %}
        </div>
    </div>
{% endfor %}
{%用于数据%中的行]
{{row.FirstName}{{row.LANSAME}}

{{row.AddressLine1}}

{%如果row.AddressLine2!=NULL或row.AddressLine2!=''%} {{row.AddressLine2}}

{%endif%} {%if row.Town!=NULL或row.Town!=''%} {{row.Town}}

{%endif%} {%if row.country!=NULL或row.country!=''%} {{row.County}}

{%endif%} {%if row.Postcode!=NULL或row.Postcode!=''%} {{row.Postcode}

{%endif%} {%endfor%}
您可以在细枝循环中使用,该循环返回循环的当前迭代,并且


这管用!然而,你的答案有一个打字错误。它是可被(10)整除的。不是可被(10)整除的。@mickburkejnr你确定这是一个打字错误吗?我猜官方文件在可整除之后也有空格
{% for row in data %}

{% if loop.index is divisible by(10) %}
 /*your page break*/
{% endif %}

{% endfor %}