Yesterday and today I had quite some fun figuring out how to create an accordion menu with bootstrap css and TypoScript in TYPO3 7.6.*
Since I nearly lost my mind and questioned my brain on the way to it, I am searching for a good solution.
Edit: moved solution to own answer and changed topic start to question
Perhaps you could use fluid for Menu rendering. Here are some examples:
https://github.com/TYPO3/TYPO3.CMS/tree/master/typo3/sysext/fluid_styled_content/Resources/Private/Partials/Menu
Yesterday and today I had quite some fun figuring out how to create an accordion menu with bootstrap css and TypoScript in TYPO3 7.6.*
Since I nearly lost my mind and questioned my brain on the way to it, I want to share you my outcome and would like to get some improvement ideas.
I have a 2 level menu where the first level is only for grouping - not linked - and the second level contains the sub pages
This is the HTML container inside my template:
# HTML part, put into your template
<div class="panel-group" id="accordion">
<f:cObject typoscriptObjectPath="lib.menu2" />
</div>
And this is my TypoScript:
# TypoScript part
lib.menu2 = HMENU
lib.menu2 {
wrap = |
1 = TMENU
1.expAll = 1
1.NO = 1
1.NO.wrapItemAndSub = <div class="panel panel-default">| </table></div></div></div>
1.NO.doNotLinkIt = 1
1.NO.allStdWrap.dataWrap = <div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{field:uid}"> | </a></h4></div><div id="collapse{field:uid}" class="panel-collapse collapse"><div class="panel-body"><table class="table">
1.IFSUB < .1.NO
1.IFSUB.allStdWrap.dataWrap = <div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{field:uid}"> | </a></h4></div><div id="collapse{field:uid}" class="panel-collapse collapse"><div class="panel-body"><table class="table">
1.CURIFSUB < .1.NO
1.CURIFSUB.allStdWrap.dataWrap = <div class="panel-heading"><h4 class="panel-title"><a data-toggle="collapse" data-parent="#accordion" href="#collapse{field:uid}"> | </a></h4></div><div id="collapse{field:uid}" class="panel-collapse collapse in"><div class="panel-body"><table class="table">
1.ACTIFSUB< .1.CURIFSUB
2 = TMENU
2.NO = 1
2.NO.linkWrap = <tr><td> | </td></tr>
}
I still a small clean up on my todolist, to remove the submenu stuff for NO where there is no submenu.
What do you think?
#firegate666, your solution was inspirational! I've modified to account for:
- subparts (note: also works with fluid, just change ###SUBPART### )
- user-generated full CSS styling (no panels)
- a (minimum) 3 level menu
HTML Template:
<!-- ###MENU### START -->
<!-- ###MENU### END -->
TYPOscript:
# declare the menu,
# wrap it in a list <ul>
# and then wrap all that in a container div (for post-processing menus like slicknav),
subparts.MENU = HMENU
subparts.MENU.wrap = <div id="menu"><ul> | </ul></div>
subparts.MENU {
# 1st level
1 = TMENU
1 {
expAll = 1
# enable the NOrmal state, wrap it in a <li>
NO = 1
NO.wrapItemAndSub = <li> | </li>
# IF item has a SUBmenu, then it's still like a NOrmal item, but more
# wrap it in Bootstrap accordion/collapse functionality
# then close it
IFSUB < .NO
IFSUB = 1
IFSUB.allStdWrap.dataWrap (
<a class="accordion-toggle collapsed" data-toggle="collapse" href="#collapse{field:uid}"> | </a>
<div id="collapse{field:uid}" class="collapse">
<ul>
)
IFSUB.wrapItemAndSub (
<li> | </li>
</ul>
</div>
)
IFSUB.doNotLinkIt = 1
}
# 2nd level sub-menu and 3rd level sub-sub-menu inherit all the properties of 1st level
2 < .1
3 < .1
# end subparts.MENU
}
...and (suggested) CSS:
.accordion-toggle:before {
content: "- ";
}
.accordion-toggle.collapsed:before {
content: "+ ";
}
I hope this addition to your code is helpful :-)
Related
I am using ExpressionEngine 2.10.3 and also Taxonomy 3 plugin. I have the following code which, when run, returns the 15 nodes I have set up:
<div class="col-md-4">
{exp:taxonomy:nav tree_id="1" display_root="no" root_node_id="2"}
<li>
{node_title}
</li>
{/exp:taxonomy:nav}
</div>
What I would like to do is after every 5 entries, end the current <div> and start a new col-md-4. Usually, I would use {switch} and I have tried it like this:
<div class="col-md-4">
{exp:taxonomy:nav tree_id="1" display_root="no" root_node_id="2"}
<li>
{node_title}
</li>
{switch='||||</div><div class="col-md-4">'}
{/exp:taxonomy:nav}
</div>
But it doesn't work at all, instead it just prints out {switch='||||'}
Is there any way of doing what I'm trying to do?
If you're on 2.7.1 or greater and your taxonomy:nav has the nav_count variable, use the modulo operator. Instead of your {switch...} thing, put
{if nav_count % 5 == 1}
</div><div class="col-md-4">
{/if}
If you end on an modulo-5 count, though, you're going to have an empty div....
I might be getting this completely wrong, but trying to create a webpage where Div 1 is in top left corner, and div 2 is aligned bottom right (or end end). And I wanted to do this in the right way using material design.
I want it like this (sorry for the ASCII art, but it is cool)
_____________33____50________________
| | |
| 1 | |
| | _________________| 33
-------------| | |
| | 2 |
| | |
| | |
--------------------------------------
50
Here is the code so far, but the problem is I can get it to affect the alignment on column one, but I cant set them independently on the two divs
<md-content layout="column" layout-fill>
<div layout="column" flex="33"><H1>Welcome to My page</H1>
</div>
<div layout="row" layout-align="end end" flex="33">
<div layout="column" layout-align="end end" flex="50">
<H3>Welcome to my page</H3>
<p>This is my page, there are many like it <bold>But this page is mine</bold></p>
<ul>
<li>
My page is my best friend
</li><li>
I must master its code
</li><li>
like I must master my life
</li>
</ul>
</div>
</div>
</md-content>
Not certain the JS fiddle works at all, managed to get the first bit working, but cant get the end. Is this just because we don't know how big the screen is?
Here is a simple JS fiddle, and Material Design is working, and I can get the flex to work, but not the align
https://jsfiddle.net/p02Ls1dh/3/
OK, sorry, me being silly, material design still don't know the height, so the way to do it is to set height (you can use javascript and window) to set the height to say 900px (style="height: 900px;" below), once that is done it works.
<md-content layout="column" layout-fill style="height: 900px">
<div layout="column" flex="33"><H1>Welcome to My page</H1>
</div>
<div layout="row" layout-align="end end" flex="33">
<div layout="column" layout-align="end end" flex="50">
<H3>Welcome to my page</H3>
<p>This is my page, there are many like it <bold>But this page is mine</bold></p>
<ul>
<li>
My page is my best friend
</li><li>
I must master its code
</li><li>
like I must master my life
</li>
</ul>
</div>
</div>
</md-content>
I am trying myself on a progress bar kind of menu in TYPO3 and have come up with the following menu. So far so good:
1 = TMENU
1 {
noBlur = 1
wrap = <ul class="crumbs-bar">|</ul>
expAll = 1
NO.wrapItemAndSub = <li class="visited first">|</li> |*| <li>|</li> |*| <li>|</li>
ACT=1
ACT.wrapItemAndSub = <li class="visited first">|</li> |*| <li class="active">|</li> |*| <li>|</li>
}
}
No what I need to add is a wrap for the previous and the next menu item (<li class="previous"> and <li class="next">) to make it work. I have found several examples of prev/next menus for TYPO3 but seem unable to integrate it into my code.
It is supposed to look something like this (assuming Item 4 is active):
Item 1 | class="first visited"
Item 2
Item 3 | class="previous visited"
Item 4 | class="active"
Item 5 | class="next"
Item 6
Item 7
And so forth...
I guess you have to write a little bit of code yourself. Take a look on the itemArrayProcFunc or IProcFunc property of the tmenu. You can find some example code in this blog post or in the statictemplates extension of TYPO3 of how to use this feature, it is in German though.
I'd like to have a horizontal menu at the top of the website and a vertical menu with the menu levels 2 and 3 at the left side of the website.
Unfortunately my typoscript shows the same menu for both areas.
Any ideas what's wrong?
# Hauptmenu
lib.mainMenu = HMENU
lib.mainMenu.special = directory
lib.mainMenu.special.value = 1
lib.mainMenu.entryLevel = 0
lib.mainMenu.1 = TMENU
lib.mainMenu.1.NO {
wrapItemAndSub = <div class="grid_1_menu"> | </div > |*| <div class="grid_1_menu"> | </div > |*| <div class="grid_1_menu grid_1_menu_end"> | </div >
}
# Seitennavigation
lib.subMenu= HMENU
lib.subMenu.special = directory
lib.subMenu.special.value = 1
lib.subMenu.entryLevel = 1
lib.subMenu.wrap = <ul class="sub-menu" id="menu-level-1">|</ul>
lib.subMenu.1 = TMENU
lib.subMenu.1.NO {
wrapItemAndSub = <li class="first"> | </li> |*| <li class="middle"> | </li> |*| <li class="last""> | </li>
}
lib.subMenu.2 < lib.subMenu.1
lib.subMenu.2.wrap = <ul class="sub-menu" id="menu-level-2">|</ul>
That's easy:
special = directory
special.value = 123
creates a menu from ALL items inserted in page or sysfolder with uid = 123 , by writing the value (1 in your case) you instruct the TS to build menu from pages under (probably) main page.
As you can see in this sample, special directive takes precedens over the entryLevel.
Allthough I don't understand exactly why, I had to remove
lib.subMenu.special.value = 1
Hy everyone. I am an neebie in Typo3 and i want to ask how is this possible to make a navigation with different colors. It must look like that
<ul>
<li>NavItem 1
<ul>
<li>SubItem1
<ul>
<li>SubsubItem1</li> <--- when active to red
</ul>
</li>
<li>SubItem2
<ul>
<li>SubsubItem2.1</li><--- when active to red
<li>SubsubItem2.2</li><--- when active to red
<li>SubsubItem2.3</li><--- when active to red
</ul>
</li>
</ul>
</li>
<li>NavItem 2</li><--- third level item to blue on active
<li>NavItem 3</li><--- third level Item to green on active
<li>NavItem 4</li>
<li>NavItem 5</li>
<li>NavItem 6</li>
</ul>
All other third level Items must be in the specified color when they active.
Is this possible in Typo3?
Thanks for your answers :)
what you are looking for is optionSplit.
f.e.
1.NO.ATagParams = class="red" || class="blue" || class="green" ...
The || indicates optionSplit - it will split each menu item.
I am not sure, if optionSplit works on ATagParams, at least you can use it on wrapItemAndSub or allWrap.
1.NO.allWrap = <li class="red">|</li> || <li class="blue">|</li> || ...