Get list of feusers with typoscript, can't get the names of the associated usergroups - select

I am generating this list of feusers and trying to get the names of the associated usergroups. This code worked before the update to TYPO3 8.x (it's just the relevant part of the whole thing):
40 = TEXT
40.field = usergroup
40.split {
token = ,
cObjNum = 1 || 2
1 {
10 = CONTENT
10.table = fe_groups
10.select.pidInList = 22
10.select.andWhere.current = 1
10.select.andWhere.wrap = uid=|
10.select.where = (title NOT LIKE 'Netzwerk')
10.renderObj = TEXT
10.renderObj.field = title
10.renderObj.wrap = |, <br />
}
2 < .1
2.10.renderObj.wrap >
}
With TYPO3 8 the 'andWhere' is depreciated and so I tried like this, but failed:
40 = TEXT
40.field = usergroup
40.split {
token = ,
cObjNum = 1 || 2
1{
10 = CONTENT
10 {
table = fe_groups
select {
pidInList = 22
where.current = 1
where.wrap = uid= |
}
10.renderObj = TEXT
10.renderObj.field = title
10.renderObj.wrap = |,
}
2 < .1
2.10.renderObj.wrap
}
}
Thanks for pointing me in the right direction.

You should not split up the comma separated values, but go for uidInList instead. This way you get rid of the surrounding split and fetch the elements within just one go.
40 = CONTENT
40 {
table = fe_groups
select {
uidInList.field = usergroup
pidInList = 22
}
renderObj = TEXT
renderObj.field = title
renderObj.wrap = |,
}

Related

TYPO3 - get last element of a splitted string

Trying to get the last part of the url as a body class. So far I got the slug of the page and split it by /
page.bodyTag >
page.bodyTagCObject = TEXT
page.bodyTagCObject.field = slug
page.bodyTagCObject.split {
token = /
cObjNum = 1
1.10 = TEXT
1.10.current = 1
1.10.noTrimWrap = | ||
1.10.dataWrap = |
1.10.required = 1
}
With this code, I am getting:
url: page/foo/bar/
class="page foo bar"
I need to get class="bar"
You'll need to use optionSplit for that. For example:
lib.test = TEXT
lib.test {
value = 1,2,3,4
split {
token = ,
cObjNum = 1 |*| 2 |*| 3
1 = TEXT
1 {
current = 1
wrap = First item:|<br/>
}
2 = TEXT
2 {
current = 1
wrap = Middle item:|<br/>
}
3 = TEXT
3 {
current = 1
wrap = Last item:|<br/>
}
}
}
1 |*| 2 |*| 3 means: use 1 for the first item, 3 for the last item and 2 for the rest.
You can just not set the ones you don't want, so this will only show the last item:
cObjNum = 1 |*| 1 |*| 2
2 = TEXT
2 {
current = 1
wrap = Last item:|<br/>
}

TYPO3 split different wrap for first line using optionSplit

I am getting the text from the abstract field and splitting it by new line.
What I want is to wrap the first line in an H5 tag and all lines after in P tags.
This is what I have tried:
tt_content.menu.20.102 = HMENU
tt_content.menu.20.102 {
1 = TMENU
1 {
NO = 1
NO {
doNotLinkIt = 1
stdWrap.cObject = COA
stdWrap.cObject {
50 = TEXT
50.stdWrap {
field = abstract
split {
token.char = 10
cObjNum = 1 || 2
1.current = 1
1.wrap = <h5>|</h5>
2.current = 1
2.wrap = <p>|</p>
}
}
}
}
}
}
But it wraps all the lines in H5... How do I make this work?
I found a bug report that mentions this issue here: https://forge.typo3.org/issues/59533
It seems the best workaround that I can see is to instead use listNum
This has the obvious drawback of only working with a limited number of paragraphs but at least it sort of works.
10 = TEXT
10.field = abstract
10.wrap = <h5>|</h5>
10.listNum = 0
10.listNum.splitChar = 10
20 < .10
20.wrap = <p>|</p>
20.listNum = 1
30 < .20
30.listNum = 2
Just a combination of both, the original code and the listNum workaround should do the job. Still have to find a way to get the rest of the first "split" into the second one. So consider this answer to be WIP please. We are still discussing it on our Coders.Care Twitch channel in the TYPO3 service station.
10 = TEXT
10.field = abstract
10.wrap = <h5>|</h5>
10.listNum = 0
10.listNum.splitChar = 10
20 < .10
20.listNum = 1
20.split {
token.char = 10
cObjNum = 1
1.current = 1
1.wrap = <p>|</p>
}

TYPO3 ignores Language in categories select

I am selecting categories on an English page. The categories have the language ID 0. English is ID 1.
But I need the same categories on both languages.
cheese = CONTENT
cheese {
wrap = <cheese_legend>|</cheese_legend>
table = sys_category
select {
pidInList = {$categories}
selectFields = *
where = deleted = 0
andWhere = sys_language_uid = 0
andWhere = hidden = 0
}
renderObj = COA
renderObj {
wrap = <cat>|</cat>
10 = TEXT
10 {
stdWrap.field = uid
stdWrap.wrap = <div>|</div>
}
20 = TEXT
20 {
stdWrap.field = title
stdWrap.wrap = <div>|</div>
}
30 = TEXT
30 {
stdWrap.field = sys_language_uid
stdWrap.wrap = <div>|</div>
}
}
}
So I'm explicitly selecting the sys_language_uid = 0!!
But nevertheless the script only gives me results with the ID = 1.
Any idea to make this baby work?
You have doubled the andWhere = statement, so the one below overwrites the one above.
Use andWhere = sys_language_uid = 0 AND hidden = 0 in one line.
For getting the english ones you use andWhere = sys_language_uid = 1 AND hidden = 0.

Select with TypoScript with condition

I got this condition:
[globalVar = TSFE:fe_user|sesData|get_car = Katowice]
get_carpid = TEXT
get_carpid.value = 27
[global]
And this select:
plugin.Tx_Formhandler.settings.predef.formhandler-multistep-forms.markers.input_readonly_a_price = CONTENT
plugin.Tx_Formhandler.settings.predef.formhandler-multistep-forms.markers.input_readonly_a_price {
table = tx_pricelist_prices_full
select {
pidInList = 27
orderBy = uid
selectFields = uid, group_a_1_3
# possible conditions
where = ( tx_pricelist_prices_full.uid='1' AND hidden='0' AND deleted='0')
}
renderObj = COA
renderObj {
#value
1 = TEXT
1.insertData = 1
1.data = field:group_a_1_3
2 = TEXT
2.value = *
3 = TEXT
3.insertData = 1
3.data = TSFE:fe_user|sesData|finish_day
stdWrap.prioriCalc = 1
}
}
How to use defined get_carpid in SELECT in line pidInList = get_carpid
Thanks for any help!
You can create a cObject CASE. But this will only work for [a-zA-z0-9_-]
# TS Setup
... snip ...
pidInList.cObject = CASE
pidInList.cObject {
key.data = TSFE:fe_user|sesData|get_car
key.case = lower
default = TEXT
default.value = 0
# special chars are not allowed
katowice = TEXT
katowice.value = 27
}
... snip ...
A different possibility is to use constants:
# TS Constants
[globalVar = TSFE:fe_user|sesData|get_car = Katowice]
get_carpid = 27
[globalVar = TSFE:fe_user|sesData|get_car = Lublin]
get_carpid = 28
[global]
# TS Setup
... snip ...
pidInList = {$get_carpid}
... snip ...
The first solution is more TypoScript fun, the second easier for novice - i guess :)

Typoscript - Splitting "media" and "imagecaption" simultaneously

I have made a plugin where I store many images in the "media" field and jsut as many captions in the field "imagecaption".
Now my wish is to display it like this:
image1.png
caption 1
image2.png
caption 2
image3.png
caption 3
This is how ive been trying to do it, but its not working:
plugin.tx_myplugin_pi1 = COA
plugin.tx_myplugin_pi1{
10 = TEXT
10.field = header
10.wrap = <h1>|</h1>
20 = COA
20{
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
}
}
20 = TEXT
20{
field = imagecaption
split{
token.char = 10
cObjNum = 1
1.current = 1
}
}
}
}
But its not really working, as it shows first all the filenames and then the caption.
How could I do it?
Split is a function which returns all elements. Within 20.10 you get the content of field image, splitted by an newline f.e. and after that, you get the content of 20.20 which has the imagecaption.
What you need to do (untested):
10 = TEXT
10{
field = media
split{
token = ,
cObjNum = 1
1.current = 1
# for each image, add the imagecaption
1.append = TEXT
1.append {
field = imagecaption
# split saves the index in REGISTER:SPLIT_COUNT
listNum.stdWrap.data = REGISTER:SPLIT_COUNT
listNum.splitChar = 10
}
}
}
I do not think that token = \n is correct. You properly need to use .char = 10.
Also you will need to nest your TS somehow, because the current solution does handle the fields one by one.
I can't remember at the moment but I've wrote an extension that adds a frame to a picture and caption. It can solve your problem with the captions: http://typo3.org/extensions/repository/view/ch_imgtext_renderengine/current/.