0

You may say that I should just change the display settings but in my use case I need to include 2 view modes inside one template as the mobile and desktop version of the output require very different HTML.

Is there a way to do this or do I require some preprocess function to do this?

Thanks

2

You could try using Twig Tweak module

{{ drupal_entity('paragraph', NUMERIC_ID, VIEWMODE_MACHINE_NAME) }}

Also see the cheat sheet for Twig tweak, it really is a great module for frontend work!

  • thank you very much, Do you know how to get the numeric ID of the paragraph? – drupalhgy May 17 '18 at 19:02
  • 2
    If you are using the paragraph.html.twig template, you can use {{ paragraph.id() }} - it's described in the code documentation of that template file. – andileco May 18 '18 at 4:18

Your Answer

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

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