Reputation: 1
I'm trying to output the value of [TSFE] [register] [initialVariable] via TypoScript in the COA tt_content.textmedia but get no output.
I've defined [initialVariable] with LOAD_REGISTER as a Fluid variable in the FLUIDTEMPLATE object of the page. (And when I output [initialVariable] within the FLUIDTEMPLATE it works.)
Here's an extract of the template: At first [initialVariable] gets defined.
page = PAGE
page {
...
10 = FLUIDTEMPLATE
10 {
...
variables {
...
counterVariable = COA
counterVariable.10 = LOAD_REGISTER
counterVariable.10.initialVariable = foo
}
}
}
Later on in the template [initialVariable] should be outputted under every textmedia object (but it doesn't work):
tt_content.textmedia = COA
...
tt_content.textmedia.40 = TEXT
tt_content.textmedia.40.data = TSFE:register|initialVariable
tt_content.textmedia.40.wrap = <p>|</p>
I know that there is no scope issue to LOAD_REGISTER since it sets global variables (the headline was just a teaser ;-)) and I know that there is only one [register] array. So why is [initialVariable] undefined when I try to output it. Does it have to do with the loading and resolving order of TypoScript?
Can anybody help? Any ideas appreciated.
Upvotes: 0
Views: 388
Reputation: 2694
Reading from the register array always works the same. It has to be
data = register:myRegisterName
The point is, that registers are working as a LIFO stack, which will be changed by using LOAD_REGISTER and RESTORE_REGISTER. So you have to make sure that each LOAD_REGISTER will get its counter part by RESTORE_REGISTER, since otherwise you will get unpredictable results due to other parts of the TypoScript using registers too. And on the other hand you have to make sure there is no additional RESTORE_REGISTER that removes your register value before using it.
And actually there is a scope issue to XXX_REGISTER, since it depends on the order in which your elements are rendered, which will influence the register stack too.
But the actualy point is: You are mixing up two different concepts, pure TypoScript with XXX_REGISTER and FLUIDTEMPLATE with variables, so the results will be pretty much unpredictable too. So you should either go for a variable or a register to avoid the problem you described.
Additionally you might want to take a look at current, setCurrent and setContentToCurrent here: https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Stdwrap/Index.html#setcontenttocurrent
But still this should not be mixed with variables and registers.
Upvotes: 0
Reputation: 6174
Remove the TSFE:
in front of it.
tt_content.textmedia.40.data = register:initialVariable
Upvotes: 0