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
}
Related
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>
}
I want to create a menu of all 2nd level items at once in separate DIVs (outside the first level menu) - independent of the active page. Do you have an hint for me? Thank you very much for your help!!
don't forget to configure
1.expAll = 1
in your typoscript menu definition
I think you are looking something like this:
lib.menu = COA
lib.menu {
# Menu of first Level
10 = HMENU
10.entryLevel = 0
10.1 = TMENU
10.1.wrap = <ul> | </ul>
10.1.NO.allWrap = <li>|</li>
# Menu of all second levels
20 = HMENU
20.entryLevel = 0
20.1 = TMENU
20.1.expAll = 1
20.1.NO.doNotLinkIt = 1
20.1.NO.doNotShowLink =1
20.1.IFSUB = 1
20.1.IFSUB.doNotLinkIt = 1
20.1.IFSUB.allWrap = <h4>2°lv (|) </h4>
20.2 = TMENU
20.2.wrap = <ul> | </ul>
20.2.NO.allWrap = <li> | </li>
}
Thank you for your answers! I found a similar solution like the one Cristian Buja posted, that works fine for me. Here's the code if someone have the same issue: `lib.subnav = HMENU
lib.subnav {
1 = TMENU
1 {
expAll = 1
NO.doNotShowLink = 1
IFSUB = 1
IFSUB.doNotShowLink = 1
IFSUB.allWrap = <div id="s{elementUid}" class="nv-sub-wrapper"><div class="nv-sub-menu clearfix">|
IFSUB.wrapItemAndSub = |<div class="nv-sub-info"></div></div></div>
IFSUB.subst_elementUid = 1
}
2 = TMENU
2 {
wrap = <ul>|</ul>
NO = 0
NO {
ATagParams = data-description="{field:abstract // field:subtitle // field:title}"
ATagParams.insertData = 1
wrapItemAndSub = <li>|</li>
}
}
}`
In my TYPO3 6.2.31 (I know...) page I have the following typoscript for the navigation:
NAVIMAIN = HMENU
NAVIMAIN.entryLevel = 0
#NAVIMAIN.excludeUidList =
NAVIMAIN {
1 = TMENU
1 {
expAll = 1
wrap = <ul class="sf-menu">|</ul>
noBlur = 1
NO = 1
NO.ATagTitle.field = title
NO.wrapItemAndSub = <li>|</li>
ACT = 1
ACT.wrapItemAndSub = <li class="active"> |</li>
}
2 = TMENU
2 {
expAll = 1
maxItems = 10
wrap = <div class="sf-mega">|</div>
NO = 1
NO {
ATagTitle.field = title
wrapItemAndSub = <div class="sf-mega-section">|</div>
stdWrap.wrap = |
ATagParams = class="headermega"
stdWrap.htmlSpecialChars = 1
doNotLinkIt = 0
}
}
3 = TMENU
3 {
expAll = 1
maxItems = 20
wrap = <ul>|</ul>
NO = 1
NO {
ATagTitle.field = title
linkWrap = <li>|</li>
}
ACT = 1
ACT {
wrapItemAndSub = <li>|</li>
ATagParams = class="active"
}
}
#4 < .3
}
All sub pages are marked as aktive when they are clicked ... but the root node not ... so I've added this as well:
[globalVar = TSFE:id=1]
NAVIMAIN.alwaysActivePIDlist = 1
[global]
[globalVar = TSFE:id=1]
NAVIMAIN.alwaysActivePIDlist = 60
[global]
But this does hasn't any effect as well.
What can I do to mark the root node as active as well?
Thanks in advance
After some Teamviewer investigations we found the source of the problem in the Typoscript structure. The [globalVar] condition was placed inside page.20.marks {} but conditions must be placed outside of any nesting.
Moving the condition outside of the nesting and correcting the path, everything worked fine.
[globalVar = TSFE:id=1]
page.20.marks.NAVIMAIN.alwaysActivePIDlist = 60
[global]
As Bernd said, [page:uid = 1] would be the better condition, too.
If you want both pages to be active you need to do another construct as in your way the second assignement would overwrite the first one.
[globalVar = TSFE:id=1]
NAVIMAIN.alwaysActivePIDlist := addToList(1)
[global]
[globalVar = TSFE:id=1]
NAVIMAIN.alwaysActivePIDlist := addToList(60)
[global]
In general you would join the two statements.
Another change I would consider: use another condition as TSFE will become obsolete in the near future:
[page:uid = 1]
NAVIMAIN.alwaysActivePIDlist = 1,60
[global]
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.
Have search the net, for a solution where i have a navi TS file that show a Menu.
here i only want to show 2 links, the links are a Main root page and a sub page, so my question is.
If i dont want to excludeUidList all the 7-9 Uid, is there a way to make a includeUidList ?
bc i can't get this to work, it showing all the Uid links.
lib.leftNavi = HMENU
lib.leftNavi.entryLevel=0
lib.leftNavi.includeUidList = 4,8
lib.leftNavi.1 = TMENU
lib.leftNavi.1 {
wrap = <div id="leftMenu"><ul class="L1"><li><ul>|</ul></li></ul></div>
expAll = 0
NO = 1
NO.allWrap = <li>|</li>
NO.stdWrap.wrap = <span>|</span>
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.allWrap = <li class="current">|</li>
CUR.stdWrap.wrap = <span>|</span>
CUR.ATagParams =
ACT < .CUR
}
No, there is no includeUidList, see the reference at http://docs.typo3.org/typo3cms/TyposcriptReference/latest/ContentObjects/Hmenu/.
But you can use a HMENU with the "special" property: http://docs.typo3.org/typo3cms/TyposcriptReference/latest/ContentObjects/Hmenu/#hmenu-special-property
20 = HMENU
20.special = list
20.special.value = 35, 56
This will generate a menu with page 35 and 36.