Use split within split in Typoscript? - typo3

Using typoscript, how do I split a field by linebreak and then split each line by : ?
This is what I have tried:
30 = TEXT
30.stdWrap {
field = abstract
split {
token.char = 10
wrap = <p>|</p>
1.current = 1
1.stdWrap.split {
token = :
wrap = <span>|</span>
}
}
}

Maybe, it's worth a look at dataProcessing...
There is also a CommaSeparatedValueProcessor which can provide CVS-like data prepared as single values for use in Fluid.

split works with some global properties, so, nesting split results into interference with values from previous split. I prefer using individual ContentObjects:
page.10 = COA
page.10.10 = LOAD_REGISTER
page.10.10.splitParts = vorname:stefan,nachname:froemken
page.10.10.splitParts.split {
token = ,
1.current = 1
}
page.10.20 = TEXT
page.10.20.data = REGISTER:splitParts
page.10.20.wrap = <p>|</p>
page.10.20.split {
token = :
wrap = <span>|</span>
1.current = 1
}
page.10.30 = RESTORE_REGISTER
Stefan

Related

Typoscript modify a field:variable

I have this typoscript:
tt_content.gridelements_pi1.20.10.setup {
3cols.outerWrap = <div>|</div>
3cols.outerWrap.override.insertData = 1
3cols.outerWrap.override = <div id="{field:tx_cewrap_id_input}" class="{field:tx_cewrap_class_input} {field:tx_cewrap_class_select}">|</div>
3cols.outerWrap.override.if.isTrue.field = tx_cewrap_active
}
Which makes sure a wrapper is made around a certain element. The following html is generated as an example:
<div id="" class="full-box full-box-features container pt-75,pb-75"></div>
As you can see there is a comma separated string inserted as "tx_cewrap_class_select". With the {field:tx_cewrap_class_select} part:
pt-75,pb-75
But i want the comma to be a space character so the classes work in html
Now I know about the split option
But how do I fix the code, just need somehow to remove the comma! That's it :)
Thanks in advance for any response I can use.
You can split by comma and join with a space, but in this case it might be easier just to replace the comma by space:
10 = TEXT
10.replacement {
1 {
search = ,
replace.char = 32
}
}
And here the solution with split. it should be obvious why not to use:
10 = TEXT
10.split {
token = ,
cObjNum = 1 || 2
1.current = 1
2.current = 1
2.noTrimWrap = | ||
}
Hint:
on TEXT you can use stdWrap functions immediately,
in other context you might need an explicit .stdWrap:
10.stdWrap.replacement {
10.stdWrap.split {
Either you prepare your values into a register for later use, or you split your override value into a COA. You even might use the replacement on the whole override value in case you are sure no other comma might be needed.
COA-Solution:
(don't forget the noTrimWrap for 20 otherwise the classes are appended without space)
override.cObject = COA
override.cObject {
10 = TEXT
10.value <div id="{field:tx_cewrap_id_input}" class="{field:tx_cewrap_class_input}
10.insertData = 1
20 = TEXT
20.field = tx_cewrap_class_select
20.replacement {
1 {
search = ,
replace.char = 32
}
noTrimWrap= | ||
}
30 = TEXT
30.value = ">|</div>
}

Typoscript operators - Value of filelink referencing to another one

I've set up the Typoscript below, but the last line doesn't work.
I want 20.filelink to have the same content as 10.filelink (the real code is more complex and that bit is redundant).
lib.test = COA
lib.test {
10 = TEXT
10.value = A value
10.filelink {
path = fileadmin/path/
target = blank
stdWrap.wrap = <li>|</li>
}
20 = TEXT
20.if.isFalse.data = subheader
20.value = Another value
20.filelink =< lib.test.10.filelink
}
Copying (with the < operator) works, but not =< as stated.
I've also tried without the lib.test. or with just = but without any success.
Is what I want to do possible?
What did I not understand about operators?
you should put it out of the curly brackets :
lib.test = COA
lib.test {
10 = TEXT
10.value = A value
10.filelink {
path = fileadmin/path/
target = blank
stdWrap.wrap = <li>|</li>
}
20 = TEXT
20.if.isFalse.data = subheader
20.value = Another value
}
lib.test.10.filelink =< lib.test.20.filelink
I figured out what I did not understand. Apparently, you can only copy or reference Content Objects.
The answer then is to reference the entire object, and to modify and add what needs changing. In this case it would be:
lib.test = COA
lib.test {
10 = TEXT
10.value = A value
10.filelink {
path = fileadmin/path/
target = blank
stdWrap.wrap = <li>|</li>
}
20 = < lib.test.10
20.if.isFalse.data = subheader
20.value = Another value
}

Typo3 mbl_newsevent post date to URL

I got an event glossary at my site and the user needs to register for that events with powermail. I post the event title to the URL and then the title gets inserted into a input field at my powermail form. But now I need the date of the event, too.
This is my code so far:
plugin.tt_news.mbl_newsevent{
registrationLink_typolink {
additionalParams.cObject = COA
additionalParams.cObject {
10 = TEXT
10 {
value = &tx_powermail_pi1[veranstaltung]={field:title}
insertData = 1
}
20 = TEXT
20 {
value = {field:tx_mblnewsevent_from}
insertData = 1
stdWrap.date = d.m.Y
stdWrap.outerWrap = &tx_powermail_pi1[datum]=|
}
}
}
output is (URL): http://preview.eloum.de/anmeldung-infotag/?tx_powermail_pi1%5Bveranstaltung%5D=Infotag%20eBusiness-Lotse%20Oberschwaben-Ulm%2028.03.2014&tx_powermail_pi1%5Bdatum%5D=01.01.1970
why 01.01.1970?
the timestamp is correct without that stdWrap.date = d.m.Y
EDIT: got it!
My solutioN:
plugin.tt_news.mbl_newsevent{
registrationLink_typolink {
additionalParams.cObject = COA
additionalParams.cObject {
10 = TEXT
10 {
value = &tx_powermail_pi1[veranstaltung]={field:title}
insertData = 1
}
20 = TEXT
20 {
field = tx_mblnewsevent_from
insertData = 1
date = d.m.Y
wrap = &tx_powermail_pi1[datum]=|
}
}
}}
Can you try
registrationLink_typolink {
...
additionalParams= &tx_powermail_pi1[veranstaltung]={field:title}&tx_powermail_pi1[datum]={field:datetime}
additionalParams.insertData = 1
}
... here's another try. I haven't tested it and I'll have to leave it there. So maybe you have to make some modifications. The general idea is that, as you can't say $date = makereadabledate($timestamp); and then use that in your template (as TS isn't a real programming language), you build the value you want to pass to additionalParams as a so called "cObject". In there, you can parse and wrap it. In the end, you would pass your string for further use to additionalParams. Hope you can make it work!
registrationLink_typolink {
...
additionalParams.cObject = COA
additionalParams.cObject {
10 = TEXT
10 {
value = &tx_powermail_pi1[veranstaltung]={field:title}
insertData = 1
}
20 = TEXT
20 {
value = {field.datetime} // or use "data"
insertData = 1
stdWrap.date = d.m.Y
stdWrap.outerWrap = &tx_powermail_pi1[datum]=|
// outerWrap: maybe not even necessary, the idea is not to interfere with the created string
// cf. http://blog.bartlweb.net/2011/02/die-reihenfolge-der-wichtigsten-wraps-in-typo3/
}
}
}

how to insert the language id in a typolink in typoscript

i want to add the language id in a typolink
so far
LOGO = COA
LOGO {
10 = TEXT
10 {
value = logo
typolink {
parameter = 116
additionalParams = &L={$config.sys_language_uid}
}
}
}
if L=4 it's working
but if i use L={$config.sys_language_uid} it gets ignored altogether
same with L=GP:L
and L=GPvar:L
what would be the proper syntax here
working if i do something like
additionalParams = COA
additionalParams {
10 = TEXT
10.data = GP : L
10.intval = 1
10.wrap = &L=|
}
You do not need to do that on your own. With the following global TypoScript configuration the parameter L will added to every link:
config.linkVars = L(int)
So, if you use HMENU.special = language this will be managed on the switch automatically, too:)
http://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Config/Index.html
I do not know about {$config.sys_language_uid}, but your code will output it as plain text. In order to use variables like {GP:L}, you got to dataWrap it or insert "insertData" after the value.
10 = TEXT
10 {
value = logo
typolink {
parameter = 116
additionalParams.dataWrap = &L={GP:L}
}
}
OR (the best way I'd say):
10 = TEXT
10 {
value = logo
typolink {
parameter = 116
additionalParams.cObject = TEXT
additionalParams.cObject {
wrap = &L=|
data = GP:L
}
}
}
Using {TSFE:sys_language_uid} might be a better option if you are querying the database.
There is no need to make a cObject or COA
additionalParams = type=0&L={GP:L}
additionalParams.insertData = 1
You can do this kind of URL using addQueryString = 1. https://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html#addquerystring

typoscript issue with LOAD_REGISTER and if condition to fill a list

What I'm trying to do is quite complex and an Extbase extension is involved...
Step by step, what I'm trying to do:
An Extbase plugin decides, if certain navigation elements should be marked.
This plugin has one action for each navigation element.
The returned value (0 or 1) from each action in TS is stored on the stack (LOAD_REGISTER).
A list of page UIDs is build by checking against the stored values (0,1).
The navigation COA is modified using this list of page UIDs.
Here is the typoscript code I'm using:
// load information, if pages lack info, into register
10 = LOAD_REGISTER
10 {
lacksAnfahrt {
cObject = USER_INT
cObject {
userFunc = tx_extbase_core_bootstrap->run
pluginName = Pa_klinik_data_edit
extensionName = Hplusinfo
controller = SpitalInfoPA
switchableControllerActions {
SpitalInfoPA {
1 = completeAnfahrt
}
}
}
}
lacksAktivitaeten < .lacksAnfahrt
lacksAktivitaeten.cObject.switchableControllerActions.SpitalInfoPA.1 = completeAktivitaeten
lacksBildergalerie < .lacksAnfahrt
lacksBildergalerie.cObject.switchableControllerActions.SpitalInfoPA.1 = completeBildergalerie
// build a list of PIDs that are going to be marked in navigation
lackPIDs.cObject = COA
lackPIDs.cObject {
10 = TEXT
10 {
value = {$config.PIDLists.anfahrt},
if {
value = 1
equals.data = register:lacksAnfahrt
}
}
20 < .10
20.value = {$config.PIDLists.bildergalerie},
20.if.equals.data = register:lacksBildergalerie
30 < .10
30.value = {$config.PIDLists.aktivitaeten},
30.if.equals.data = register:lacksAktivitaeten
// don't let the comma separated list end with a comma
99 = TEXT
99.value = 0
} // lackPIDs
} // REGISTER
// mark incomplete pages with a red exclamation mark
20 { // = HMENU
1 { // = TMENU
NO { // = 1
stdWrap.wrap = |<span class="warning lacksInfo">!</span>
stdWrap.wrap.if {
value.data = register:lackPIDs
isInList.field = uid
}
}
}
}
If i print out register:lacksBildergalerie and all the others, their values are correct (0 or 1).
But the lackPIDslist always empty (except of the 0 at the end)... There must be something wrong with the middle part:
10 {
value = {$nav.PIDLists.anfahrt},
if {
value = 1
equals.data = register:lacksAnfahrt
}
}
This evaluation seams to return false in any case.
I also tried with different if function like:
10 {
value = {$nav.PIDLists.anfahrt},
if {
isTrue.data = register:lacksAnfahrt
}
}
But this doesn't solve the problem.
Just overlooked that the other registers are using USER_INT as well