DRUPAL 8 | Add Slider using Paragraphs

July 17th, 2018

1) Slider Fileds Definitions:

  • Create a paragraphs field: structure > paragraphs type > add
  • Define fields that you need for the slider ( images, caption, link, ecc ecc )

2) Create a Personalized block

  • Create a block type, structure -> block -> block-content -> add
  • Add as field type the paragraphs field created before
  • Once Create a block type, add a personalized field under structure -> block layout -> Personalized fields library -> add, and chose the block type created in the fist two steps
  • Once you have created the field you can compile the slide fields

3) Associate block to region

  • Open your template file yourtheme.info.yml and create new region under regions section.
  • Copy from modules -> paragraphs -> templates the file pharagraph.html.twig, paste in themes -> custom -> yourtheme_name -> template and rename in paragraph–block-name.html.twig, and add your slider markup
  • If you need it register the slider librares ( css and js ) under yourtheme.libraries.yml
  • Under Structure -> Blocks Layout click on ” Add Block” in the region create before, and add the personalized block created before

4) Clean cache , reload page, and you see your slide.