0

I am working on a site with different layouts for certain sections on a landing page and our work page. (please see screenshot Layout 1)

my current thinking in regarding this is the following.

I used paragraphs where a paragraph can have title, image, class_field and a link_field.

the link field will determine which class wraps around the content block ie flex-30 which has a style class in my css. The content editor will determine this depending on how they want the blocks to appear. enter image description here

So this is like a 3 column setup, split in 60% and 30%

My question is, whether my following approach is fine, and how can i loop through and print the paragraph fields in my page-node--front.html.twig and other twig files eg. page-node--our-work.html.twig.

Would a views approach be the best solution, for this?

Hope I can get some help regarding this

  • No need to involve views, from what you have described. You can just add the class in the paragraph template and maybe some scaffolding in your node template. (That layout looks like a nightmare to make responsive, but that's a different discussion.) – Alfred Armstrong Jul 19 '18 at 9:52
  • so printing the values from the two paragraphs, eg grid layout being the the holding div and content include being the referenced paragraph within the grid layout would be something like this: {{ node.field_blocks_include.entity.field_block_title.value }} in page-node-front.html.twig – Lloyd_07 Jul 19 '18 at 10:13
  • If you have paragraphs as an entity reference field in a node, the standard node template will print them. If you want to pull out that one field and wrap it in some extra grid html, follow this example: drupal.stackexchange.com/questions/244711/… – Alfred Armstrong Jul 19 '18 at 10:17
  • ok i checked that link out to no avail. did a {{ kint(node) }} and the referenced field does show up() 'field_content_block' => array (size=1) 'x-default' => object(Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList) now accessing those fields in my twig file is the issue, maybe am missing something. should i not create a theme_suggestions_block_alter in my .theme although according to this issue one doesn't really need it drupal.stackexchange.com/questions/247023/… – Lloyd_07 Jul 19 '18 at 12:55
  • No, you should be theming the individual paragraphs using their own template. drupal.org/docs/8/modules/paragraphs/… – Alfred Armstrong Jul 19 '18 at 13:47

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.