Как вывести первые 6 элементов меню а не все сразу в opencart коде?

Есть такой код:

<ul class="us-footer-list  list-unstyled">
    {% for information in informations %}
    <li class="us-footer-item us-footer-information"><a href="{{ information.href }}" {% if information.rel is defined and information.rel %}rel="nofollow"{% endif %} class="us-footer-link">{{ information.title }}</a></li>
    {% endfor %}
</ul>


Этот код выводит сразу все li элементы в ul, а мне надо только первые шесть.
  • Вопрос задан
  • 175 просмотров
Решения вопроса 1
neuotq
@neuotq
Прокрастинация
Так как вы используете Twig в качестве шаблонизатора, то можно сделать так:
<ul class="us-footer-list  list-unstyled">
    {% for information in informations | slice(0, 6) %}
    <li class="us-footer-item us-footer-information"><a href="{{ information.href }}" {% if information.rel is defined and information.rel %}rel="nofollow"{% endif %} class="us-footer-link">{{ information.title }}</a></li>
    {% endfor %}
</ul>
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 03:52
1000 руб./за проект
19 апр. 2024, в 03:01
1000 руб./за проект
18 апр. 2024, в 21:56
2000 руб./за проект