Hide element if not element in a list iteration - typo3

So I have 2 list of string in 2 fields, altText and imagecaption. I have them wrapped in a div. I want to make the div not render if neither have content in some loop, on each iteration of the loop. How can I do it?
30 = COA
30{
wrap = <div class="case-info">|</div>
required = 1
30 = TEXT
30{
wrap = <div>|</div>
field = altText
listNum.splitChar = 10
listNum.stdWrap.data = register:SPLIT_COUNT
required = 1
}
40 < .30
40.field = imagecaption
}
The output of html is this:
<div class="case-info">
<div></div>
<div></div>
</div>

Remove the wrap and try it this way:
30 = COA
30{
stdWrap.required = 1
stdWrap.wrap = <div class="case-info">|</div>
30 = TEXT
30{
field = altText
listNum.splitChar = 10
listNum.stdWrap.data = register:SPLIT_COUNT
trim = 1
required = 1
wrap = <div>|</div>
}
40 < .30
40.field = imagecaption
}
so, the wrap will only executed, if there is content (required = 1)

Related

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 Breadcrumb with stdWrap.data possible?

I am new to Typo3 and wanted to have something like this: date / page1 > page2 > page3...
I know how to make a simple breadcrumb but now I wonder how I can put the current date in front of it. When I try the stdWrap.data + stdWrap.dataWrap the breadcrumb doesn't show.
20 = HMENU
20 {
special = rootline
special.range = 0 | -1
stdWrap.data = date : d.m.Y :::
stdWrap.dataWrap = <p> | </p>
//wrap = <p> | </p>
1 = TMENU
1 {
NO = 1
NO.allWrap = | >
CUR = 1
CUR.allWrap = |
}
}
Currently I don't know if I had to write to objects in typoscript for it or if I could do it in once like I tried. Maybe you can hint me to something or explain a simple way. Thanks!
You need to do a proper wrapping.
20.stdWrap.data
is no wrap at all and will be ignored so you might only get an empty p-tag from the stdWrap.dataWrap.
Following your attempt I think you want something like:
20.dataWrap = <p>{date:d.m.Y}</p> |
so I don't get it why you use a p tag to get all in one line.
I would propose a different TypoScript:
lib.breadcrumb = COA
lib.breadcrumb {
stdWrap.wrap = <ul>|</ul>
10 = TEXT
10 {
wrap = <li>|</li>
data = date : U
strftime = %A, %e. %B %Y
}
20 = HMENU
20 ... your TS for the breadcrumb menu
}

Typoscript Use value in Text Wrap multiple times

In a Templavoila FCE i want to achieve the following from an input field:
<a name="Inputvalue">Inputvalue</>
My current Setup is the following:
10 = TEXT
10.current = 1
10.wrap = <a name="|"> | </a>
But for sure, it just fill out the first pipe:
<a name="Inputvalue"></a>
Any Idea how to achieve that in a simple way?
Got it!
I did it this way:
10 = COA
10 {
wrap = |
10 = TEXT
10.current = 1
10.rawUrlEncode = 1
10.wrap = <a name="|">
20 = TEXT
20.current = 1
20.wrap = | </a>
}

Typoscript - Simplifying passing parameters to an object

I have the following object in Typoscript, that I want to reuse several times:
module.headedmenu = COA
module.headedmenu{
10 = HMENU
10{
wrap = <nav><ul><li>|</li></ul></nav>
special = list
special.value = ###ROOTID###
1 = TMENU
1.NO.doNotLinkIt = 1
}
20 = HMENU
20{
wrap = <nav><ul>|</ul></nav>
special = directory
special.value = ###ROOTID###
1 = TMENU
1{
#Do we really need this??
expAll= 1
NO = 1
NO.wrapItemAndSub = <li class="first-level">|</li>
ACT = 1
ACT.wrapItemAndSub = <li class="first-level active">|</li>
}
}
}
This can be reused like this:
10 < module.headedmenu
10.10.special.value = 3
10.20.special.value = 3
20 < module.headedmenu
20.10.special.value = 12
20.20.special.value = 12
Is there a way to refactor this, so that I do not need to input more than once the root id? Constants dont cut it, because I want to use it several times. I do not want to have a huge constant list. I want to use it, more like a function that can be passed paramenters.
Is this doable?
You can use registers:
# Query register where the root id is needed:
module.headedmenu {
[...]
special.value = {register:rootId}
special.value.insertData = 1
[...]
}
# Set register before rendering element, and
# restore it afterwards:
10 = COA
10 {
10 = LOAD_REGISTER
10 {
rootId = 3
}
20 < module.headedmenu
30 = RESTORE_REGISTER
}

get Image from Pageproperties into an HMENU

I have an HMENU in Typo3, in the Pageproperties i have stored an image. How can i show the Image from the Pageproperties in ne Menu? I have no Idea, why the image is not displayed.
Typo3 6.2
lib.produkt_start = HMENU
lib.produkt_start {
special = directory
special.value = 3
wrap = |
1 = TMENU
1 {
expAll = 1
NO = 1
NO {
allWrap = <div class="patterns col4" id="page_{field:uid}">|</div>
allWrap.insertData = 1
ATagParams = id="uid{field:uid}"
ATagParams.insertData = 1
stdWrap.cObject >
stdWrap.cObject = COA
stdWrap.wrap = |
stdWrap.cObject {
10 = TEXT
10.field = title
10.wrap = <br /><h2>|</h2>
10.insertData = 1
20 = TEXT
20.wrap = <p><span>|</span></p>
20.field = subtitle
30 = IMAGE
30.file.import.data = levelmedia-1, slide
30.treatIdAsReference = 1
30.import.listNum = 0
30.wrap = <h5>|</h5>
}
}
ACT = 1
ACT < .NO
}
}
I tested your problem with TYPO3 6.1.7
First of all you have to correct you code a little:
[...]
stdWrap.cObject {
10 = TEXT
10.field = title
10.wrap = <br /><h2>|</h2>
10.insertData = 1
20 = TEXT
20.wrap = <p><span>|</span></p>
20.field = subtitle
30 = IMAGE
30.file.import.data = levelmedia:-1, slide
30.file.treatIdAsReference = 1
30.file.import.listNum = 0
30.wrap = <h5>|</h5>
}
[...]
Now it will be "working" but only if you actually set an image in media field of the parent page, then it will be renderd in all child pages, ignoring the fact that the child pages have an own image set - I would consider this as sort of a bug of TMENU or TMENUITEM, but I haven't realy testet it fully.
You will get a problem with entity encoding of the title as well so I would try this option:
stdWrap.wrap.cObject = COA
stdWrap.wrap.cObject {
10 = TEXT
10.value = <br><h2>|</h2>
20 = TEXT
20.wrap = <p><span>|</span></p>
20.field = subtitle
30 = IMAGE
30.file.import.data = levelmedia:-1, slide
30.file.treatIdAsReference = 1
30.file.import.listNum = 0
}
Strange is that the following does not work either:
30.file.import.field = media
This makes my suspition of the wrong slide behaviour above being a bug even stronger.