【问题标题】:How can i display second items drupal 9 for loop我如何显示第二个项目drupal 9 for loop
【发布时间】:2022-06-22 10:53:15
【问题描述】:

目前只能获取第一个和最后一个项目,那么我如何显示第二个项目?谢谢你的时间

{% if content.field_story_sub_stories['#items']|length > 0 %}
    {% for story in content.field_story_sub_stories['#items']|first %}
        {{ drupal_entity('node', story.value , 'env_series_2022') }}
    {% endfor %}
{% endif %}

【问题讨论】:

    标签: php for-loop drupal


    【解决方案1】:

    尝试:

    {% if content.field_story_sub_stories['#items']|length > 1 %}
        {% for story in content.field_story_sub_stories['#items'][1] %}
            {{ drupal_entity('node', story.value , 'env_series_2022') }}
        {% endfor %}
    {% endif %}
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-18
      • 2013-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      相关资源
      最近更新 更多