Urs
Urs

Reputation: 5122

Prevent TypoScript from cascading?

I have this in nearly every project: TypoScript cascades to child nodes in the pagetree by default. If you want to prevent it from being applied to child nodes, one solution is to create an extra TS template that undoes it and include it as "template on next level".

E.g. you want to apply some TS to a specific parent page, but not it's children:

temp.somemenu.wrap = **|**

Apart from the "template on next level" approach, solutions/hacks include:

if you know which level you start from:

[treeLevel = 2]
  temp.somemenu.wrap = **|**
[global]

If you have the pid and want to wire it in a constant:

[page|uid = {$targetPagePid}]
  temp.somemenu.wrap = **|**
[global]

EDIT: adapted to constant – this is quite a robust solution!

Isn't there some switch to make a TS setting NOT cascade? Or define the number of levels it can cascade to?

Something like

<INCLUDE_TYPOSCRIPT: source="path/to/my.ts" treeLevelsDown="0">

or

[global treeLevelsDown = 0]
  temp.somemenu.wrap = **|**
[global]

This would mean that the TS is kind of self-aware, knowing on which tree level it has been set. Not sure if that's even possible.

Does it make sense?

Or am I missing some existing solution?

Upvotes: 1

Views: 75

Answers (2)

Urs
Urs

Reputation: 5122

The question is theoretical, and @pgampe answers it.

About my use case, here's the solution from @bernd-wilke-πφ, which works just fine

// just apply to page references
[page|uid = {$pidReferencesList}]

// add some additional js (a list filter) 
page.includeJSFooter {
  refs = {$templatePath}/Resources/Public/additional_js/references.js
}
// add some markup
lib.thecontent.wrap =   <div id="items-list-wrapper">|</div>

[global]

Upvotes: 0

pgampe
pgampe

Reputation: 4578

No, this does not work any other way than those you already mentioned in your question. The reason for this is, that TYPO3 start from a page and the looks upwards the page tree, until it finds a TypoScript template. (It collects all extension templates on the way and applies them on top of the first found root template).

Therefore it never goes down, but only up. If it would stop cascading after a certain level, what should be used as TypoScript template for those sites? It still needs a configuration to render the page.

Upvotes: 1

Related Questions