1
votes

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?

2
Can you describe what you are talking about? What menu type is the temp.somemenu and what do you want to wrap there? - Dimitri L.
1st: instead of [globalVar = TSFE:id=80] you should use [page|uid = 80]. 2nd: you can use TS-constants in your (setup-)conditions to be somewhat more flexible: [page|uid = {$pid.special}]. and don't forget: you also can use multiple values in conditions [page|uid = {$pid.special},{$pid.main}]. But as Dimitri asked: what do you want to achieve? maybe there is another solution. - Bernd Wilke πφ
This is perfect! I'm working with pids in constants all the way anyway. I wasn't aware you could use them in conditions. About the "what for": the question is also theoretical, and your solution is more than sufficient for me. Still, I'll post my use case, see answers - Urs

2 Answers

1
votes

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.

0
votes

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]