Prevent rendering nested content elements created by `content_blocks` extension

Open
#1,554 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
backend, content

Research direction

Start by locating the lib.dynamicContent TypoScript configuration and reproduce the nested content-block case described in the issue with TYPO3 v12.4. Check how the Content Blocks extension contributes nested tt_content records to the selection. Done means the nested content is rendered only once without affecting ordinary dynamic content rendering.

Written by the indexing model from the issue text.

Description

bug

Bug Report

Prerequisites

  • Can you reproduce the problem on TYPO3 v11.5 LTS
  • Can you reproduce the problem on TYPO3 v12.4 LTS
  • Did you perform a cursory search
    to see if your bug or enhancement is already reported?

Description

When creating nested content element with content blocks the content rendered twice on same page.
The lib.dynamicContent schould be modified to prevent such case.

Possible solution:

# Prevent rendering nested content elements created by `content_blocks` extension
[extension.isLoaded('content_blocks') == 1]
    lib.dynamicContent.20.select.where {
        postUserFunc = TYPO3\CMS\ContentBlocks\UserFunction\ContentWhere->extend
    }
[end]

I can provide a PR if needed.

Steps to Reproduce

  1. Create a simple nested content element with content blocks:
name: example/tabs
fields:
  - identifier: header
    useExistingField: true
  - identifier: tabs_item
    type: Collection
    minitems: 1
    foreign_table: tt_content
<f:for each="{data._grids.tabs_item}" as="item" iteration="i">
    <f:comment><!-- {item.data} contains the Content Block data object. --></f:comment>
    <div class="tab-item" data-uid="{item.data.uid}">
        <f:comment><!-- {item.content} contains the rendered html. --></f:comment>
        <f:format.raw>{item.content}</f:format.raw>
    </div>
</f:for>

Expected behavior

Content should be only rendered once.

Actual behavior

Content rendered twice.

Screenshots

Image

Versions

TYPO3 v12.4.27
Content Blocks v0.7.19
PHP v8.2

Dominant language
PHP
Stars
354
Forks
209
Avg merge
1m
Merged PRs (30d)
2

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from benjaminkott/bootstrap_package

All issues in benjaminkott/bootstrap_package

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.