CMS 1.0 Navigation tutorial
I am trying to find a decent tutorial on cms navigation for top menu items or left menu items, using blocks. This will be very helpful for newbie like me, I can contribute it myself if there can be some help to show me the way.
Comments
http://docs.getfuelcms.com/general/navigation
I maintain categories using a module and now I have to show categories under the projects menu-item.
btw thanks for your guidance and support, Ithink fuel rocks and i look forward to contributing the best i can, right now I have to learn my way around it.
Can you let me know if this can be generated as is? or do i have to modify my javascripts and css. notice each submenu items is placed in a div and classes are used for links instaed of li elements.
My nav menu format template is:
<div id="menu"> <ul class="menu"> <li><a href="#" class="parent"><span>Home</span></a> <div><ul> <li><a href="#" class="parent"><span>Sub Item 1</span></a> <div><ul> <li><a href="#" class="parent"><span>Sub Item 1.1</span></a> <div><ul> <li><a href="#"><span>Sub Item 1.1.1</span></a></li> <li><a href="#"><span>Sub Item 1.1.2</span></a></li> </ul></div> </li> <li><a href="#"><span>Sub Item 1.2</span></a></li> <li><a href="#"><span>Sub Item 1.3</span></a></li> <li><a href="#"><span>Sub Item 1.4</span></a></li> <li><a href="#"><span>Sub Item 1.5</span></a></li> <li><a href="#"><span>Sub Item 1.6</span></a></li> <li><a href="#" class="parent"><span>Sub Item 1.7</span></a> <div><ul> <li><a href="#"><span>Sub Item 1.7.1</span></a></li> <li><a href="#"><span>Sub Item 1.7.2</span></a></li> </ul></div> </li> </ul></div> </li> <li><a href="#"><span>Sub Item 2</span></a></li> <li><a href="#"><span>Sub Item 3</span></a></li> </ul></div> </li> <li><a href="#" class="parent"><span>Product Info</span></a> <div><ul> <li><a href="#" class="parent"><span>Sub Item 1</span></a> <div><ul> <li><a href="#"><span>Sub Item 1.1</span></a></li> <li><a href="#"><span>Sub Item 1.2</span></a></li> </ul></div> </li> <li><a href="#" class="parent"><span>Sub Item 2</span></a> <div><ul> <li><a href="#"><span>Sub Item 2.1</span></a></li> <li><a href="#"><span>Sub Item 2.2</span></a></li> </ul></div> </li> <li><a href="#"><span>Sub Item 3</span></a></li> <li><a href="#"><span>Sub Item 4</span></a></li> <li><a href="#"><span>Sub Item 5</span></a></li> <li><a href="#"><span>Sub Item 6</span></a></li> <li><a href="#"><span>Sub Item 7</span></a></li> </ul></div> </li> <li><a href="#"><span>Help</span></a></li> <li class="last"><a href="#"><span>Contacts</span></a></li> </ul> </div>
I don't quite see " classes are used for links instaed of li elements" however, I do see the span tags. To wrap the text in a span tag, you can use the "pre_render_func" parameter which would map to a custom function that you would need to setup that simply wraps the label value (e.g. "Sub Item 3") in a span tag:
function span_wrap($label){ return '<span>'.$label.'</span>'; } echo fuel_nav(array('pre_render_func' => 'span_wrap'));
echo fuel_nav(array( 'container_tag_id' => 'menu1', 'container_tag_class' => 'topmenu', 'first_class' => 'topfirst', 'last_class' => 'toplast', 'active_class' => 'active', 'item_id_prefix' => 'topmnenu_', 'append' => array('sub-menu1'=>array('label' => 'sub-menu1', 'parent_id' => 'topmnenu_7')) ) );
Also please advise what syntax is for style option in fuel_nav. i cant find an example of that either.
The "style" attribute is used to add classes to the item "li" elements. It works as an array syntax that can be nested. So for example, if you have a menu that you want the following classes applied:
<ul> <li class="class1"><a href="http://mysite.com">Item 1</a></li> <li><a href="">Item 2</a> <ul> <li class="class2.1"></li> <li class="class2.2"></li> </ul> </li> </ul>
echo fuel_nav('styles' => array('class1', array('class2.1', 'class2.2')))
i am using cms based navigation and from what i understand so far, if CMS nav is used then fuel will not read the nav file. But i have even tried putting the code in nav file but it does not render to the topmenu item referenced via the id.
Style:
thanks for the details, i may not need the jquery now.
can you guide me to make the profiler work, i feel like shooting in the dark. What is the best way to debug in fuel?
$append[] = array('id' => 'about/history', 'label' => 'History', 'parent_id' => 3);// where 3 is the ID value of "about"
If you are using the _variables/nav.php file it can be the array key value (which is normally a string like:
$nav["about/history"] = array('label' => 'History');
If there is data in the CMS for the navigation module, then it will use that by default unless you specify the 'file' parameter for fuel_nav().