Typoscript - Splitting "media" and "imagecaption" simultaneously - typo3

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/.

Related

TYPO3 GIFBUILDER with image from FLUID

I want to use the GIFBUILDER to make an image with an overlay. The image should therefore be delivered via FLUID.
This is what I have so far:
FLUID
<f:for each="{product.images}" as="image">
<f:cObject typoscriptObjectPath="lib.overlay" data="{image: image.uid}" />
</f:for>
TypoScript
lib.overlay = IMAGE
lib.overlay {
file = GIFBUILDER
file {
XY = 300,500
format = jpg
quality = 80
10 = IMAGE
10 {
file.import = {field:image}
file.import.insertData = 1
file.import.treatReferenceAsId = 1
}
20 = TEXT
20 {
text = Copyright
fontColor= #dddddd
fontSize = 30
offset = 100,100
align = left
antiAlias = 1
}
}
}
At the moment, I only get a white Background with the label Copyright on it. However if I do somethinge like
10 = IMAGE
10.file = fileadmin/path/to/file
all works just fine.
So my question is: How do I pass the Image from FLUID correctly to TypoScript?
And as addition to this, how do I pass a value from the Contentelement via FLUID to make the overlay text dynamic too?
Best regards and Thanks in advance
UPDATE:
output of {image} (one image):
Replace
10 = IMAGE
10 {
file.import = {field:image}
file.import.insertData = 1
file.import.treatReferenceAsId = 1
}
with
10 = IMAGE
10 {
file.import.field = image
file.treatIdAsReference = 1
}
treatReferenceAsId should be treatIdAsReference. It's also a property of file, not of file.import. I'm not sure why file.import = {field:image} and insertData = 1 doesn't work, but file.import.field = image does. It's cleaner anyway, which is why I tried it.
You might also want to add a width and height or maxW and maxH to the image, unless you're 100% sure they're always 300x500 pixels.

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>
}

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

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 = |,
}

List of images as subpart in Typo3

At current I'm making a list of images for a banner slider using code as follows:
page.10.marks.topimage = IMAGE
page.10.marks.topimage {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 0
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
wrap = <div id="slides">|
}
page.10.marks.topimage1 = IMAGE
page.10.marks.topimage1 {
file.import.data = levelmedia: -1, "slide"
file.import = fileadmin/user_upload/
file.import.override.field = media
file.import.current = 1
file.import.listNum = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
etc...
However, this means, every time the other admins want to add a new slide or remove one from the total count, I have to change this code. Adding the content of the slides is not a problem, they simply upload to user_upload and it pulls 0 to 3 at current. However, they want to be able to upload 5 images and have it show 5 or just 3 and have it show 3 and I need a more dynamic way to implement this. I'm still new to Typo3 (i really don't understand it, php is 10,000X easier!), so if anyone could, please explain to me better than the docs, how subparts work or what my solution might be.
And no I can't just write an extension to do it. Been there and tried that and still can't figure out how to get extensions in without breaking it.
FYI, if you could break it down and help me "like" it, that would be great, because at current, I'd rather they use wordpress or joomla or ANYTHING but this. If you've seen my other questions, then you'll realize, i've had 0 fun working with this cms and mostly because the documentation and/or "help" i've received has been almost completely useless to me. I only mention this so that maybe someone will break this down for me like i break down jquery/php/.net questions for others. It doesn't hurt to be polite and show a nub "step-by-step" instructions!
page.10.marks.topimage = TEXT
page.10.marks.topimage {
# retrieve data
data = levelmedia: -1, "slide"
override.field = media
# we have some filenames in a list, let us split the list
# and create images one by one
# if there are five images selected, the CARRAY "1" will be executed
# five times where current is loaded with only one filename
split {
# the images are separated via ","
token = ,
# you can do funny stuff with options split, f.e. if you want to give first
# and last image a different class... but thats another topic;)
# we just say, render every splitted object via CARRAY "1"
cObjNum = 1
1 {
# just render the single image,
# now there should be one filename in current only
10 = IMAGE
10 {
file.import.wrap = fileadmin/user_upload/|
file.import.current = 1
border = 0
file.height = 670
file.width = 1800
altText = Banner
titleText = Banner
}
}
}
}

TYPO3 - Markup using Math

So lets say I have something like this:
20 = CONTENT
20{
table = tt_content
select{
pidInList = 1
where = colPos = 0
}
renderObj = COA
renderObj{
wrap = <div class="normal">|</div>
10 = TEXT
10{
field = bodytext
}
}
}
and I want that every third object changes the class "normal" by "special". How could I do such operation in Typoscript?
Use optionSplit (DE) for this task on the wrap value, you need abcabc pattern where a,b = normal, c = special, so most probably it will be something like this:
wrap = a||b||c |*| a||b||c
Wrote it from top of my head so you need to check it.