TYPO3: typoscript wrap two elements with div - typo3

is it possible to wrap always two <li> elements in a div in typoscript?
at the moment it looks like this:
navStatic = HMENU
navStatic {
special = directory
special.value = 2
excludeUidList = 2
1 = TMENU
1 {
expAll = 1
wrap = <ul class="headernavmenu">|</ul>
noBlur = 1
NO = 1
NO {
ATagTitle.field = title
wrapItemAndSub = <li>|</li>
allWrap = | I |*| | I |*| |
}
ACT < .NO
ACT.ATagParams = class="active_static"
}
}
thanks in advance

This addition to your TypoScript should do the job, just when an odd number of li-elements is in the list the last single li-element is not wrapped.
NO.wrapItemAndSub.outerWrap = <div class="two-list-elements"> || || </div>
Be advised that this HTML-solution is error-prone as browsers might interpret it different or not at all because the HTML is not standard-conform.

Related

How to split menu in parts with typoscript

I have a Typoscript menu with a lot of items and want to split it into several blocks of 6 items each.
My typoscript looks like this at the moment:
lib.mainnav = HMENU
lib.mainnav {
1 = TMENU
1 {
wrap = <ul>|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
NO.stdWrap.htmlSpecialChars = 1
NO.ATagParams = name = "{field:title}"
NO.allStdWrap.insertData = 1
}
[ ... ]
}
After every 6th item a </ul><ul> should be inserted here. I have already tried a lot of things, but have not yet reached the desired result.
Does anyone have a tip for me?
Thanks in advance for your help!
NO.wrapItemAndSub = <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li> || <li>|</li></ul><ul> |*| |*|
Keep in mind that you will have an empty <ul></ul> if you have a multiple of 6 entries in your menu.

Typo3: Output of all 2nd level pages as menu independent of active pages

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

TYPO3 mark root page as active

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]

Mathematical Operations with Typoscript

I'm trying to divide a number (12 in my case, due to using Foundation's Front End framework) by the number of pages that will appear in the typoscript-rendered menu of a page and output the result as part of a class name of the html menu items.
Currently, I can get typoscript to output the number of items in a menu with {register:count_menuItems}, but I can't figure out how to divide this number and output the quotient.
Below is my code:
lib.navigation.secondary = HMENU
lib.navigation.secondary {
entryLevel = 1
stdWrap.dataWrap = <div class="row large-10 small-centered large-centered columns">|</div>
1 = TMENU
1 {
NO {
allWrap = <div class="large-{register:count_menuItems} small-12 columns first">|</div> |*| <div class="large-{register:count_menuItems} small-12 columns">|</div> |*| <div class="large-{register:count_menuItems} small-12 columns last">|</div>
allWrap.insertData = 1
stdWrap.cObject = COA
stdWrap.cObject {
# getting the navigation title with fallback to the title
10 = TEXT
10.field = nav_title // title
10.wrap = <h4>|</h4>
# getting the subtitle of the page
20 = TEXT
20.field = subtitle
20.wrap = <p>|</p>
}
}
}
}
I couldn't test it, but I think you can solve it by this approach:
First create a LOAD_REGISTER containing the result of the calculation:
page.5 = LOAD_REGISTER
# the default value
page.5.divClass = 12
page.5.divClass.cObject = TEXT
page.5.divClass.cObject {
value = 12
stdWrap.dataWrap = |/{register:count_menuItems}
prioriCalc = 1
}
Then use it in your navigation:
lib.navigation.secondary = HMENU
lib.navigation.secondary {
entryLevel = 1
stdWrap.dataWrap = <div class="row large-10 small-centered large-centered columns">|</div>
1 = TMENU
1 {
NO {
allWrap = <div class="large-{register:divClass} small-12 columns first">|</div> |*| <div class="large-{register:divClass} small-12 columns">|</div> |*| <div class="large-{register:divClass} small-12 columns last">|</div>
allWrap.insertData = 1
[...]
The tricky part could be the rendering order of the menu; I'm not sure if at the time you're creating your LOAD_REGISTER divClass the register count_menuItems is already available.
The following ended up working for me
NO {
before.cObject = LOAD_REGISTER
before.cObject {
menuItems.cObject = TEXT
menuItems.cObject {
current = 1
setCurrent.data = register:count_menuItems
setCurrent.wrap = 12/|
prioriCalc = 1
}
}
allWrap = <div class="large-{register:count_menuItems} small-12 columns first">|</div> |*| <div class="large-{register:count_menuItems} small-12 columns">|</div> |*| <div class="large-{register:count_menuItems} small-12 columns last">|</div>
allWrap.insertData = 1
...

Typoscript navigation setup

I am new to typo3 and I have to setup a navigation. I have already done the tutorials found at Timerate and I have built the demo navigation (week 2 in the tutorial).
Now I have to setup a navigation that must look like :
Link 1 | Link 2 | Link 3 | Link 4
the back en structure is the following :
Link 1
Link 2
Link 3 (shortcut to sub link 1)
Sublink 1
Sublink 2
Link 4
The whole menu is working fine when I am in section designated by link 1, link 2 and link 4 but there is nothing showing when I click on link 3.
The Sublinks are to be shown in a secondary navigation
Here is the typoscript that I have on my root ts template (I'm using TemplaVoila) :
lib.field_topmenu = HMENU
lib.field_topmenu {
special = directory
special.value = {$idMain}
entryLevel = 2
1 = TMENU
1.NO = 1
1.wrap = <div id="menu"><ul> | </ul></div>
1.NO.wrapItemAndSub = <li>|</li>
1.ACT < .1.NO
1.ACT.ATagParams = class='active'
2 < .1
}
What would be the best way to achieve this?
glad you're on board of TYPO3.
As far as I can remember, there's no effect on the entry level of a special = directory.
That's a working solution:
lib.field_topmenu = HMENU
lib.field_topmenu {
special = directory
special.value = 1
1 = TMENU
1.NO = 1
1.wrap = <ul> | </ul>
1.NO.wrapItemAndSub = <li>|</li>
1.ACT < .NO
1.ACT.ATagParams = class='active'
2 < .1
}
You should remove the id=menu as it will be repeated the levels downwards, therefore invalidating your HTML
Here's a solution we usually use, it also uses subtitles etc. and adds special classes to the first and last elements of your navigation list:
lib.navi.one = HMENU
lib.navi.one {
1 = TMENU
1 {
noBlur = 1
wrap = <ul>|</ul>
NO = 1
NO {
wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
altText = subtitle // title
title = subtitle // title
}
CUR < .NO
CUR.wrapItemAndSub = <li class="active first">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
ACT < .CUR
}
2 < .1
3 < .2
4 < .2
}
you can quite easily adopt it to your directory starting point (and take away levels 3 & 4):
lib.field_topmenu < lib.navi.one
lib.field_topmenu {
special = directory
special.value = {$idMain}
3 >
4 >
}
aTagParams doesn´t work with shortcuts. you have to put the real pages into the sys folder than it will work.