TYPO3: dropdown login box (menu) - typo3

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.

Related

Count Childrens in a TYPOSCRIPT menu

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

TYPO3 display the subpages of sysFolder directory on menu

I have a strange behavior of TYPO3 menu, when one of the page is sysFolder, the subpages of this folder don't show in the menu. If I change this type to not visible in menu, the subpages still don't show up.
The code of my menu looks like this:
[PIDinRootline = 1234]
lib.left-menu = COA
lib.left-menu.1 = HMENU
lib.left-menu.1 {
entryLevel = 2
expAll = 1
1 = TMENU
1.noBlur = 1
1 {
wrap = <nav class="left-menu"><ul>|</ul></nav>
expAll = 0
noBlur = 1
NO {
wrapItemAndSub= <li class="inactive first">|</li> |*| <li class="inactive">|</li> |*| <li class="inactive last">|</li>
ATagParams =
}
CUR=1
CUR {
wrapItemAndSub= <li class="cur_inactive first">|</li> |*| <li class="cur_inactive">|</li> |*| <li class="cur_inactive last">|</li>
ATagParams =
}
CURIFSUB=1
CURIFSUB {
wrapItemAndSub= <li class="cur_active first">|</li> |*| <li class="cur_active">|</li> |*| <li class="cur_active last">|</li>
ATagParams =
}
ACT=1
ACT {
wrapItemAndSub= <li class="cur_active first">|</li> |*| <li class="cur_active">|</li> |*| <li class="cur_active last">|</li>
ATagParams =
}
}
2 = TMENU
2.noBlur = 1
2 {
wrap = <ul>|</ul>
expAll = 0
NO{
ATagTitle.field = title
wrapItemAndSub = <li>|</li>
}
CUR=1
CUR {
wrapItemAndSub= <li class="cur_active2">|</li>
ATagParams =
}
CURIFSUB=1
CURIFSUB {
wrapItemAndSub= <li class="cur_active2">|</li>
ATagParams =
}
ACT = 1
ACT {
wrapItemAndSub = <li class="active2">|</li>
}
}
}
[end]

optionSplit repeats only first item in Typoscript

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

Typoscript navigation with subpages

I am trying to implement my navigation with typoscript and I am having problems to understand how to wrap right.
I already have a base navigation with 1 level that is working fine.
Now I have pages that has subpages and other that don't have.
For the ones without subpages I want the behavior that I have now.
For the pages with subpages I want to add this as an dropdown menu.
The HTML code should look like this.
<ul class="nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Test0
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li class="">DropwDownItem1</li>
</ul>
</li>
<li class="active">Test1</li>
<li>Test2</li>
<li>Test3</li>
</ul>
TypoScript:
lib.menu = HMENU
lib.menu {
special = list
special.value = 3,2
1 = TMENU
1 {
wrap = <ul class="nav">|</ul>
expAll = 1
NO.wrapItemAndSub = <li class="">|</li>
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.wrapItemAndSub = <li class="active">|</li>
ACT < .CUR
IFSUB = 1
IFSUB.wrapItemAndSub= <li class="dropdown">|</li>
IFSUB.ATagParams = class="dropdown-toggle" data-toggle="dropdown"
IFSUB.stdWrap.innerWrap= |<b class="caret"></b>
ACTIFSUB = 1
ACTIFSUB.wrapItemAndSub= <li class="dropdown">|</li>
ACTIFSUB.ATagParams = class="dropdown-toggle" data-toggle="dropdown"
ACTIFSUB.stdWrap.innerWrap= |<b class="caret"></b>
CURIFSUB = 1
CURIFSUB.wrapItemAndSub= <li class="dropdown">|</li>
CURIFSUB.ATagParams = class="dropdown-toggle" data-toggle="dropdown"
CURIFSUB.stdWrap.innerWrap= |<b class="caret"></b>
}
2 = TMENU
2 {
wrap = <ul class="dropdown-menu">|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
}
//EDIT: I have changed the code but now when I click on an item in the dropdown menu the ul class="dropdown-menu" is wrapped two times and the dropdown isn't shown properly.
The option noBlur is removed since TYPO3 v6.0 and I read somewhere, that the RO state does something with javascript to show/hide the submenu - so I try not to use it. I rather do the showing/hiding via css.
I would've done it like this:
lib.menu = HMENU
lib.menu {
special = list
special.value = 3,2
1 = TMENU
1 {
expAll = 1
wrap = <ul class="nav">|</ul>
NO.wrapItemAndSub = <li>|</li>
CUR = 1
CUR.wrapItemAndSub = <li class="active">|</li>
ACT < .CUR
}
2 = TMENU
2 {
wrap = <ul>|</ul>
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
}
Add the hover-effect via CSS:
.nav ul {
display: none;
}
.nav li:hover ul {
display: block;
}
The <ul> wrap of your subnavi should be around the TMENU. I don't think you need the ATagBeforeWrap as it only makes linkWrap within the <a> tag. So it should look like this (not tested):
lib.menu = HMENU
lib.menu {
special = list
special.value = 3,2
1 = TMENU
1 {
wrap = <ul class="nav">|</ul>
expAll = 1
NO.wrapItemAndSub = <li class="">|</li>
RO < .NO
RO = 1
CUR < .NO
CUR = 1
CUR.wrapItemAndSub = <li class="active">|</li>
ACT < .CUR
noBlur = 1
IFSUB = 1
IFSUB.wrapItemAndSub= <li class="dropdown">|</li>
}
2 = TMENU
2 {
wrap = <ul class="dropdown-menu">|</ul>
expAll = 1
noBlur = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
}
Here you can find good info about wraps, unfortunately it's in german: http://jweiland.net/typo3/typoscript/wrap-moeglichkeiten-und-hierarchie-in-menues.html
By the way: if you are using TYPO3 6+ the noBlur setting has been removed.
---> EDIT:
I shortened your code a little, but I really coudn't reproduce the problem. For me it's working fine. The li around the dropdown gets the dropdown class. But I don't see a duplicate of the <ul class="dropdown-menu">
special = list
special.value = 3,2
1 = TMENU
1 {
wrap = <ul class="nav">|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li class="">|</li>
RO < .NO
CUR < .NO
CUR.wrapItemAndSub = <li class="active">|</li>
ACT < .CUR
IFSUB = 1
IFSUB.wrapItemAndSub= <li class="dropdown">|</li>
IFSUB.ATagParams = class="dropdown-toggle" data-toggle="dropdown"
IFSUB.stdWrap.innerWrap= |<b class="caret"></b>
ACTIFSUB < .IFSUB
CURIFSUB < .IFSUB
}
2 = TMENU
2 {
wrap = <ul class="dropdown-menu">|</ul>
expAll = 1
NO = 1
NO.wrapItemAndSub = <li>|</li>
}
This snippet I have used for internal page links:
I have used subtitle field for internal navigation.
for example:
<a href="#about>about</a>
Ourservice
menu.main_menu = HMENU
menu.main_menu {
#special = directory
#special.value = 2
1 = TMENU
1 {
wrap = <ul class="nav navbar-nav navbar-right">|</ul>
expAll = 1
noBlur = 1
NO = 1
NO {
doNotLinkIt = 1
allWrap.insertData = 1
allWrap = <li class="first menu-{field:uid}">|</li>
}
ACT < .NO
ACT {
ATagParams = class="active dropdown"
allWrap = <li class="active first menu-{field:uid}">|</li> |*| <li class="active menu-{field:uid}">|</li>
}
CUR < .NO
CUR {
ATagParams = class="parent_menu active"
allWrap = <li class="first active menu-{field:uid}">|</li> |*| <li class="active menu-{field:uid}">|</li>
}
}
}

TypoScript: {field:uid} replacement not working | Different CSS class per menu item

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>