Skip to main content
added 42 characters in body
Source Link
Brad Bell
  • 67.6k
  • 6
  • 75
  • 145

I want to show entries according to an array.

This is my code:

            {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
            {% set navsubidarray = [] %}
            
            {% for navsubid in navsubids %}
                    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
            {% endfor %}
            
            {% set navsubidarray = navsubidarray|join(', ') %}

            {{ navsubidarray }}<br>

            {% for entry in craft.entries.id('{{ navsubidarray }}') %}
                {{ entry.title }}<br>
            {% endfor %}

The variable gives back that what I need (18, 17, 19, 4, 20, 21, 22, 23)(18, 17, 19, 4, 20, 21, 22, 23) but the for entry loop isn't returning anything.

I want to show entries according to an array.

This is my code:

            {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
            {% set navsubidarray = [] %}
            {% for navsubid in navsubids %}
                    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
            {% endfor %}
            {% set navsubidarray = navsubidarray|join(', ') %}

            {{ navsubidarray }}<br>

            {% for entry in craft.entries.id('{{ navsubidarray }}') %}
            {{ entry.title }}<br>
            {% endfor %}

The variable gives back that what I need (18, 17, 19, 4, 20, 21, 22, 23) but the for entry loop isn't returning anything.

I want to show entries according to an array.

This is my code:

            {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
            {% set navsubidarray = [] %}
            
            {% for navsubid in navsubids %}
                    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
            {% endfor %}
            
            {% set navsubidarray = navsubidarray|join(', ') %}

            {{ navsubidarray }}<br>

            {% for entry in craft.entries.id('{{ navsubidarray }}') %}
                {{ entry.title }}<br>
            {% endfor %}

The variable gives back that what I need (18, 17, 19, 4, 20, 21, 22, 23) but the for entry loop isn't returning anything.

Source Link

Using a variable with array of ElementIds to use in craft.entries.id

I want to show entries according to an array.

This is my code:

            {% set navsubids = craft.amNav.getNavRaw("hoofdnavigatie", {startFromId:25})  %}
            {% set navsubidarray = [] %}
            {% for navsubid in navsubids %}
                    {% set navsubidarray = navsubidarray|merge([navsubid.elementId]) %}
            {% endfor %}
            {% set navsubidarray = navsubidarray|join(', ') %}

            {{ navsubidarray }}<br>

            {% for entry in craft.entries.id('{{ navsubidarray }}') %}
            {{ entry.title }}<br>
            {% endfor %}

The variable gives back that what I need (18, 17, 19, 4, 20, 21, 22, 23) but the for entry loop isn't returning anything.