Rendering a custom block with Twig Tweak more than once on a page results in the same content.

Created on 16 February 2023, over 1 year ago

Problem/Motivation

I have a paragraph that calls a custom block plugin using the Twig Tweak patch from https://www.drupal.org/project/block_ajax/issues/3315618 ✨ Twig Tweak/Plugin Blocks support Fixed .

The block receives as an argument the paragraph ID. The build logic of the block makes decisions about what content to show.

This paragraph is used twice on the page. Both paragraphs end up with the same content.

Steps to reproduce

Using Twig Tweak, render the same block twice but different content is expected.

Here's my example code from the paragraph that is used twice on a page:

{{ drupal_block('pc_passthrough_block', { 'segment_set_paragraph_id': paragraph.id(), 'block_ajax': { 'is_ajax': 1, 'max_age': '0', 'show_spinner': 1, 'placeholder': 'loading....', 'ajax_defaults': { 'method': 'GET', 'timeout': '10000', 'others': { 'async': 'async', 'cache': 0 } } } }) }}

Easier to explain with the screencast:
https://www.loom.com/share/e9f2e5e3a03644c1b2a69c2c326b0a4d

Proposed resolution

Use a unique identifier for each instance a given block ID on a single page.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States capellic Austin, Texas

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024