Skip to content

Instantly share code, notes, and snippets.

@pixelstorm
Last active August 25, 2024 07:36
Show Gist options
  • Save pixelstorm/b6134581d45b466e176d4182cfbe533d to your computer and use it in GitHub Desktop.
Save pixelstorm/b6134581d45b466e176d4182cfbe533d to your computer and use it in GitHub Desktop.
starting point for drupal paragraph block, just the html stuff and a twig variable for block_name.
{% set block_name = "example_class" %}
{% set classes = [
'paragraph',
'paragraph--type--' ~ paragraph.bundle|clean_class,
view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
not paragraph.isPublished() ? 'paragraph--unpublished',
block_name
] %}
{% block paragraph %}
{% block content %}
<section class="{{ attributes.addClass(classes) }}">
<div class="container">
{{ content }}
{{ dump(content) }}
</div>
</section>
{% endblock %}
{% endblock paragraph %}
@pixelstorm
Copy link
Author

pixelstorm commented Aug 25, 2024

this approach will work with paragraph fields add directly on the page. Not when referencing microcontent or content reference entity.

@pixelstorm
Copy link
Author

pixelstorm commented Aug 25, 2024

if your block does use microcontent.. then reference you microcontent field from {{ content.your_micro_content }}

@pixelstorm
Copy link
Author

If you have a blank page.. and your creating blocks. this is a good starting point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment