I tried using optionsplit with TMENU in TS, but it keeps repeating only first part, and I don't know why...
Here is TS:
temp.meni5col= HMENU
temp.meni5col.special = list
temp.meni5col.special.value = 5417, 5418, 5419, 5420, 5421
temp.meni5col.wrap= <div class="dropdown_5columns"><div class="col_1"><ul>|</ul></div></div>
temp.meni5col.1 = TMENU
temp.meni5col.1{
expAll = 1
NO {
linkWrap = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
}
}
And here is HTML it generated:
<div class="dropdown_5columns">
<div class="col_1">
<ul>
<li class="first">Servisi</li>
<li class="first">Usluge</li>
<li class="first">Dodatne usluge</li>
<li class="first">Tarifni modeli</li>
<li class="first">Ponuda uređaja</li>
</ul>
</div>
</div>
I just realized optionSplit is not working. It shouldn't apply class="first" to all menu items.
Is there option in TYPO3 configuration for this function that needs to be enabled?
My TYPO3 version is 4.5.17.
Thanks!
It's because linkWrap is of data-type wrap. Use stdWrap to do an optionSplit.
http://docs.typo3.org/typo3cms/TyposcriptReference/MenuObjects/Tmenuitem/Index.html
Related
I would like to create a dropdown login box in the menu. When users hover over "login" in the menu, it shows the login or register form. I found an example here: https://www.planet-sports.com/en/
I am quite new to TYPO3 so I don't know where I should start. Is there a way to do this with Typoscript only or should I modify the navbar with html and javascript? What is the best way to do this ?
EDIT: I am using a custom theme (not done by myself)
The Menu is called in a "header.html" file like this:
<nav class="collapse navbar-collapse navbar-main-collapse" role="navigation">
<f:cObject typoscriptObjectPath="menu.navbar" />
</nav>
Typoscript for the navbar:
menu.navbar = HMENU
menu.navbar {
entryLevel = 0
excludeUidList = 112
1 = TMENU
1 {
expAll = 1
stdWrap.dataWrap = <ul class="nav navbar-nav colum-{register:count_menuItems}">|</ul>
NO {
htmlSpecialChars = 1
wrapItemAndSub = <li id="navbar{field:uid}" class="first" >|</li> |*| <li id="navbar{field:uid}">|</li> |*| <li id="navbar{field:uid}" class="last navbar-right">|</li>
wrapItemAndSub.insertData = 1
ATagTitle.field = description // subtitle
}
ACT = 1
ACT {
htmlSpecialChars = 1
wrapItemAndSub = <li id="navbar{field:uid}" class="first active">|</li> |*| <li id="navbar{field:uid}" class="active">|</li> |*| <li id="navbar{field:uid}" class="last active navbar-right">|</li>
wrapItemAndSub.insertData = 1
ATagTitle.field = description // subtitle
}
IFSUB = 1
IFSUB {
ATagTitle.field = description // subtitle
wrapItemAndSub = <li id="navbar{field:uid}" class="dropdown first">|</li> |*| <li id="navbar{field:uid}" class="dropdown">|</li> |*| <li id="navbar{field:uid}" class="dropdown last">|</li>
wrapItemAndSub.insertData = 1
stdWrap.htmlSpecialChars = 1
ATagParams = class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"
linkWrap = |<span class="caret"></span>
ATagBeforeWrap = 1
}
ACTIFSUB < .IFSUB
ACTIFSUB = 1
ACTIFSUB.wrapItemAndSub = <li id="navbar{field:uid}" class="dropdown first active">|</li> |*| <li id="navbar{field:uid}" class="dropdown active">|</li> |*| <li id="navbar{field:uid}" class="dropdown last active">|</li>
}
2 = TMENU
2 {
expAll = 1
wrap = <ul class="dropdown-menu">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = |*| <li class="odd">|</li> || <li class="even">|</li> |*|
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = |*| <li class="odd active">|</li> || <li class="even active">|</li> |*|
}
3 = TMENU
3 {
expAll = 1
wrap = <ul class="dropdown-submenu">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
}
4 = TMENU
4 {
wrap = <ul class="dropdown-submenu-1">|</ul>
NO.htmlSpecialChars = 1
NO.wrapItemAndSub = <li class="first">|</li> |*| <li>|</li> |*| <li class="last">|</li>
ACT = 1
ACT.htmlSpecialChars = 1
ACT.wrapItemAndSub = <li class="first active">|</li> |*| <li class="active">|</li> |*| <li class="active last">|</li>
}
}
first of all: the visibility of a layer can be handled with CSS (even fade in/fade out or explode/implode). just put all content in a div which is included in the trigger div.
How you get your content into this div depends of the kind you build your page. fluid-template, marker-template, pure typoscript.
there are multiple ways to get the login form (and other content) into the div: create it by typoscript, get the content from a fix page, get the content from a special column which is inherited to all subpages (slide).
just be a little be more specific what your current configuration is, what you are familiar with and what you want to achieve.
I am new in TYPO3, I would like to know if it is possible to transform (using typoscript) the following structure of html-css menu in TYPO3 Hmenu. It is a multilevel structure with html lists.
<ul class="nav navbar-nav">
<!-- Home -->
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
Home
</a>
<ul class="dropdown-menu">
<li>Option 1: Default Page</li>
<!-- One Page -->
<li class="dropdown-submenu">
Option 2: One Page
<ul class="dropdown-menu">
<li><a target="_blank" href="One-Pages/Classic/index.html">- One Page Template</a></li>
<li><a target="_blank" href="One-Pages/Classic/one_page_dark.html">- One Page Dark Option</a></li>
</ul>
</li>
<!-- End One Page -->
</ul>
</li>
<!-- End Home -->
<!-- Pages -->
<li class="dropdown">
<a href="javascript:void(0);" class="dropdown-toggle" data-toggle="dropdown">
Pages
</a>
<ul class="dropdown-menu">
<!-- About Pages -->
<li class="dropdown-submenu">
About Pages
<ul class="dropdown-menu">
<li>About Us </li>
<li>About Us 1</li>
</ul>
</li>
<!-- End About Pages -->
<!-- Service Pages -->
<li class="dropdown-submenu">
Service Pages
<ul class="dropdown-menu">
<li>Our Services</li>
</ul>
</li>
<!-- End Service Pages -->
</ul>
</li>
<!-- End Pages -->
</ul>
It is possible, please read the very detailed manual here.
lib.textmenu = HMENU lib.textmenu {
# We define the first level as text menu.
1 = TMENU
# We define the normal state ("NO").
1.NO = 1
1.NO.allWrap = <li>|</li>
# We define the active state ("ACT").
1.ACT = 1
1.ACT.wrapItemAndSub = <li>|</li>
# Wrap the whole first level.
1.wrap = <ul class="level1">|</ul>
# The second and third level should be configured exactly
# the same way.
# In between the curly brackets, objects can be copied.
# With the dot "." we define that the object can be found
# in the brackets.
# With 2.wrap and 3.wrap we overwrite the wrap, which was
# copied from 1.wrap.
2 < .1
2.wrap = <ul class="level2">|</ul>
3 < .1
3.wrap = <ul class="level3">|</ul>
}
If you already know TypoScript, then here are the references: HMENU, TMENU, TMENUITEM
i am wondering if there is a way in TYPOSCRIPT to count the childrens in a menu.
The output should be something like:
<ul class="ebene1" data-elements="4">
<li>Element 1</li>
<li>Element 2</li>
<li>Element 2</li>
<li>Element 2</li>
</ul>
My Code looks like this:
script.NAV = HMENU
script.NAV {
special = directory
special.value = 6
1 = TMENU
1 {
expAll = 1
noBlur = 1
wrap = <ul class="menu main" id="nav-main">|</ul>
NO = 1
NO.wrapItemAndSub = <li class="first element1">|</li> |*| <li class="element1">|</li> |*| <li class="last element1">|</li>
CUR = 1
CUR.wrapItemAndSub = <li class="first element1 current">|</li> |*| <li class="element1 current">|</li> |*| <li class="last element1 current">|</li>
...
Thanks, any help is really appreciated.
Use the register {register:count_MENUOBJ} like this should solve your problem.
1 = TMENU
1 {
NO = 1
NO {
wrapItemAndSub.insertData = 1
wrapItemAndSub = <li class="element-{register:count_MENUOBJ}">|</li>
}
}
Actually although that may be done as #Marcus showed (I believe that snippet works, didn't check) it is probably faster approach to us JavaScript for this; as easy as:
<ul class="ebene1">
<li>Element 1</li>
<li>Element 2</li>
<li>Element 3</li>
<li>Element X</li>
</ul>
<script>$('.ebene1').attr('data-elements', $('.menu > li').length);</script>
And CSS like:
.ebene1[data-elements="4"] {
background-color: yellow;
}
On the other hand...
If you have dynamic menu with unknown number of items, instead adding many CSS declarations like,
.ebene1[data-elements="3"] li {width: 33.333%;}
.ebene1[data-elements="4"] li {width: 25%;}
.ebene1[data-elements="5"] li {width: 20%;}
Avoid adding the data- attribute via JS and just change the width by calculating the correct value:
$('.ebene1 > li').css({width: 100 / $('.ebene1 > li').length + '%'});
You need the stdWrap function numrows. There you can add any table together with a select statement. Here is an example:
lib.countmenu = COA
lib.countmenu {
10 = HMENU
10.1 = TMENU
10.1 {
wrap = <ul>|</ul>
NO {
stdWrap.cObject = COA
stdWrap.cObject {
30 = TEXT
30.numRows.table = pages
30.numRows.select.pidInList.field = uid
30.numRows.select.where = nav_hide!=1 AND doktype!=5 AND doktype!=6
30.dataWrap = {field:title} [|]
}
wrapItemAndSub = <li>|</li>
}
}
}
I have a header menu and try to define different CSS classes for each item.
This is what I have:
20 = HMENU
20 {
special = directory
special.value = 107
1 = TMENU
1 {
wrap = <ul class="foo" id="mymenu">|</ul>
expAll = 1
NO = 1
NO.allWrap = <li class="first menu_{field:uid}">|</li> || <li class="menu_{field:uid}">|</li> || <li class="last menu_{field:uid}">|</li>
}
}
But in the HTML output I simply get class="first menu_{field:uid}" and nothing is replaced.
By the way: The page entries in the menu are links to external pages.
EDIT:
As our designer complained about the non-speaking class IDs we are abusing the body-class attribute now:
NO.allWrap = <li class="first {field:bodyclass_wrap_class}">|</li> || <li class="{field:bodyclass_wrap_class}">|</li> || <li class="last {field:bodyclass_wrap_class}">|</li>
You have to add NO.allWrap.insertData = 1, then the data will be inserted. allWrap is just a normal stdWrap, so the default features apply there.
BTW: I think your option split is still wrong. I guess you want to have it like this:
NO.allWrap = <li class="first menu_{field:uid}">|</li> |*| <li class="menu_{field:uid}">|</li> |*| <li class="last menu_{field:uid}">|</li>
I have this piece of HTML
<div id="fileTreeInviati">
<ul class="php-file-tree">
<li class="pft-directory">
A006 - SOMETEXT (<span name="contaNew"></span>)
<img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>
<ul style="display: none;">
<li class="pft-file ext-png">
cut.png
</li>
<li class="pft-file ext-dll">
Safari.dll
</li>
</ul>
</li>
<li class="pft-directory">
A012 - SOMETEXT (<span name="contaNew"></span>)
<img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>
<ul style="display: none;">
<li class="pft-file ext-jpg">
04.jpg
</li>
<li class="pft-file ext-dll">
Safari.dll
</li>
</ul>
</li>
<li class="pft-directory">
A014 - SOMETEXT (<span name="contaNew"></span>)
<img src="./moduli/home/images/info.png" title="Informazioni Azienda" class="imgInfo"/>
<ul style="display: none;">
<li class="pft-file ext-txt">
acu.txt
</li>
<li class="pft-file ext-dll">
Safari.dll
</li>
</ul>
</li>
</ul>
I'm working on a js snippet that cycle through all "a" of the "li" and checks if it has the class "new" if yes increment a counter by one. This counter now has to be printed on the relative "li" "span" 3 level before.
So I have the number of the element with the "new" class.
The js snippet is this
$("#fileTreeInviati .php-file-tree .pft-directory li").each(function(){
$(this).children("a").each(function(i,e){
if ($(e).hasClass("new")){
cont++;
console.log($(e).text());
$(this).parent().parent().parent().children("a").children("span").text(cont);
}
})
cont = 0;
});
I think I'm almost there but the counter is always 1. I think there is something mess with .children, maybe it can handle only the first occurrence?
Thanks for help
Why not just use .length instead?
$('#fileTreeInviati .php-file-tree .pft-directory li a.new').length;
Update: If you want to count every li element separately, use this:
$('#fileTreeInviati .php-file-tree .pft-directory li').each(function() {
alert($('a.new', this).length);
})
OK, I figure out how to do the magic:)
Here it is:
cont = 0;
$('#fileTreeInviati .php-file-tree .pft-directory').each(function() {
$(this).children("ul").children("li").children("a.new").each(function(i,e){
cont++;
$(e).parent().parent().parent().children("a").children("span").text(cont);
});
cont=0;
});
Now all works perfect. If you think this can do in a better way, lemme know.
Bye