Using module https://www.drupal.org/project/paragraphs.

On Admin side I have made content as a 3 level categories. Main Category, Sub Category, Sub Category.

Each category have their content as well.

On twig file when i print

{{ content }}

It display all data. Which is correct.

I need to fetch individual category & their content & do the styling for each.

How can i retrieve that each field in loop?

enter image description here

  • When you have 3 levels of paragaphs you not only get 3 different paragraph templates, where you can print {{ content }}, but also 3 levels of field templates, where you'll find for each field the loop {% for item in items %} you are looking for.
    – 4uk4
    Nov 15, 2017 at 7:33
  • Hi @4k4 I added image in question. Still not get. Can you please explain further? Do u link or reference of that?
    – Mike
    Nov 15, 2017 at 7:58

1 Answer 1


You can use this template file:


    <div{{ attributes }}>
        {% for item in items %}
            <div{{ item.attributes }}>{{ item.content }}</div>
        {% endfor %}
  • So need to overwrite Category Template then Question & Answer Template as well
    – Mike
    Nov 15, 2017 at 9:09
  • Only if you want to change the html markup specific for these fields and/or paragraph types.
    – 4uk4
    Nov 15, 2017 at 9:15
  • Yes. Need to change HTML only. Have to do in overwrite 3-4 templates. Instead can we get all things in Main File by Loop?
    – Mike
    Nov 15, 2017 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.