Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserttags do not parse within the breadcrumb module #7105

Open
zoglo opened this issue Apr 10, 2024 · 11 comments
Open

Inserttags do not parse within the breadcrumb module #7105

zoglo opened this issue Apr 10, 2024 · 11 comments
Labels
Milestone

Comments

@zoglo
Copy link
Contributor

zoglo commented Apr 10, 2024

Affected version(s)

5.3.x

Description

It was common to use the insert tag {{page::pageTitle}} for detail pages in news to generate the page title within the breadcrumb.

This seems broken in Contao 5.3.x and can even be seen in the demo when using {{page::pageTitle}}:
https://demo.contao.org/news/new-contao-versions-in-short-intervalls.html
image

@zoglo zoglo changed the title Using inserttag {{page::pageTitle}} for detail pages in news does not show the title within breadcrumbs anymore Inserttags do not parse within the breadcrumb module Apr 10, 2024
@fritzmg
Copy link
Contributor

fritzmg commented Apr 10, 2024

Sort of a duplicate of #6050. While the cause in #6050 is different (here it is caused by the more granular replacement of insert tags) the eventual solution likely needs to be the same.

// edit: oh, they are not replaced with the page title at all? That's something different then may be.

@asaage
Copy link

asaage commented Apr 10, 2024

it works if the breadcrumb comes after the reader
https://community.contao.org/de/showthread.php?86441-order-of-operations&p=581453#post581453
I'd appreciate if somebody finds a solution where you don't even have to insert {{page::pageTitle}} into the pageName because it makes the PageTreeview in the Backend look like a hack.

@zoglo
Copy link
Contributor Author

zoglo commented Apr 10, 2024

I'd appreciate if somebody finds a solution where you don't even have to insert {{page::pageTitle}} into the pageName because it makes the PageTreeview in the Backend look like a hack.

@asaage feel free to adjust the logic and implement it for Contao. It ain't flawless and needs some tests as well:
https://github.com/oveleon/contao-glossary-bundle/blob/main/src/EventListener/BreadcrumbListener.php

That would most likely be a feature tho

@zoglo
Copy link
Contributor Author

zoglo commented Apr 11, 2024

After debugging, this happens most likely within these lines:

$strRegExpStart = '{{' // Starts with two opening curly braces
. '(' // Match the contents of the tag
. '[a-zA-Z0-9\x80-\xFF]' // The first letter must not be a reserved character of Twig, Mustache or similar template engines (see #805)
. '(?>[^{}]|' // Match any character not curly brace or a nested insert tag
;
$strRegExpEnd = ')*+)}}'; // Ends with two closing curly braces
$tags = preg_split(
'(' . $strRegExpStart . str_repeat('{{(?:' . substr($strRegExpStart, 3), 9) . str_repeat($strRegExpEnd, 10) . ')',
$strBuffer,
-1,
PREG_SPLIT_DELIM_CAPTURE
);

since it outputs $tags with a size of 1, thus returning a ChunkedText.

@ausi
Copy link
Member

ausi commented Apr 11, 2024

After debugging, this happens most likely within these lines:

what do you mean by that?

@zoglo
Copy link
Contributor Author

zoglo commented Apr 11, 2024

what do you mean by that?

Basically how far my investigation went.
$tags is actually an array that looks like this:

$tags = [
    '',
    '{{page::pageTitle}},
    ''
]

Basically, the regex does not work because the expected output should look like this:

$tags = [
    'page',
    'pageTitle',
]

@ausi
Copy link
Member

ausi commented Apr 11, 2024

$tags is actually an array that looks like this:

No, it looks like ['', 'page::pageTitle', ''] (the middle part without {{ and }})
But anyway, this is not related to this issue as far as I can tell, as the {{page::pageTitle}} insert tag itself works just fine, only in the breadcrumb module there seems to be an issue, right?

@zoglo
Copy link
Contributor Author

zoglo commented Apr 11, 2024

Yeah, debugged late at night so maybe a wrong conclusion

@netzarbeiter
Copy link
Member

netzarbeiter commented Apr 16, 2024

As an addition: If you add a headline with the content {{page::pageTitle}} to the news detail page the output in Contao 5 is "News and updates" the page title of the page. In Contao 4.13 it was the title of the news "New Contao Versions in short intervalls".

https://demo.contao.org/preview.php/news/new-contao-versions-in-short-intervalls.html

@Toflar Toflar added this to the 5.3 milestone Apr 18, 2024
@asaage
Copy link

asaage commented Apr 24, 2024

As an addition: If you add a headline with the content {{page::pageTitle}} to the news detail page

I noticed the same while using a detail-page with the reader-module from plenta/contao-jobs-basic-bundle.
Is it possible to delay the resolving of this Inserttag {{page::pageTitle}} (probably others as well) until every module that changes something has done it's thing? The culprit seems to be located there more than actualy in the breadcrumb module.

@fritzmg
Copy link
Contributor

fritzmg commented Apr 24, 2024

I still think that the correct solution for this issue are - in my opinion - reader pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants