0

I have two paragraph types called First Type & Second Type and added Image & Text fields on it separately. I have created the basic page & added the two above paragraphs(First Type & Second Type) with multiple values.

Its showing only one value of each paragraph, but I have multiple values. So mainly its not rendering/iterate the values properly.

Here is my field--field-page-detail-paragraph.html.twig file

   {% set first = {} %}
    {% set second = {} %}

{% for key, item in items %} // looking for the bundle items to display

        {% set bundle = item.content['#paragraph'].type.target_id %}

        {% if bundle == "first_type" %}
            {% set first = item.content %}

        {% elseif bundle == "second_type" %}
            {% set second = item.content %}

        {% endif %}

{% endfor %}

    <section class="home">
        <div class="container">
            <div class="row">
                <div class="span8">
                    {{ first }}
                </div>                   
                <div class="span4">
                    {{ second }}
                </div>                 
            </div>
        </div>
    </section>

paragraph--first-type.html.twig file

    <div class="row">
        <div class="span12">
            {{ content.field_message }}
            {{ content.field_image }}
        </div>                            
    </div>

paragraph--second-type.html.twig file

    <div class="row">
        <div class="span12">
            {{ content.field_test }}
            {{ content.field_link }}
        </div>                            
    </div>

Can anyone let me know what's issue & how to display all values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.