Problem with main navigation

edited May 2015 in Modules
Hi,

I have a complex main navigation structure and I am evaluating if I can use the fuel navigation class for building the menu...

My main navigation has following structure ( a live example is the main navigation on www.feuerwehr-bs.de):
<ul id="menu"> <li><a href="...">Main Nav Level #1 Item #1</a> <div class="dropdown"> <ul> <li class="headline"><a href="...">Level #2 Item #1</a></li> <!-- following items are read from the database table of a simple module --> <li><a href="..."><span class="subline">17.03.2015</span><br />DB Item #1</a></li> <li><a href="..."><span class="subline">17.03.2015</span><br />DB Item #....</a></li> <li><a href="..."><span class="subline">17.03.2015</span><br />DB Item #5</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #2</a></li> <!-- following items are read from the database table of a simple module --> <li><a href="..."><span class="subline">04.04.2015 / Hilfeleistungseinsatz</span><br />DB Item #1</a></li> <li><a href="..."><span class="subline">04.04.2015 / Hilfeleistungseinsatz</span><br />DB Item #...</a></li> <li><a href="..."><span class="subline">04.04.2015 / Hilfeleistungseinsatz</span><br />DB Item #5</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #3</a></li> <!-- following items are read from the database table of a simple module --> <li><a><span class="subline">09.04.2015 / 19:30:00 Uhr</span><br />DB Item #1</a></li> <li><a><span class="subline">09.04.2015 / 19:30:00 Uhr</span><br />DB Item #...</a></li> <li><a><span class="subline">09.04.2015 / 19:30:00 Uhr</span><br />DB Item #5</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #4</a></li> <!-- following items are read from the database table of a simple module --> <li><a href="..." class="fancybox-gallery" rel="gallery_presse_menue"><span class="subline">30.03.2015 / Frankfurter Neue Presse</span><br />DB Item #1</a></li> <li><a href="..." class="fancybox-gallery" rel="gallery_presse_menue"><span class="subline">30.03.2015 / Frankfurter Neue Presse</span><br />DB Item #...</a></li> <li><a href="..." class="fancybox-gallery" rel="gallery_presse_menue"><span class="subline">30.03.2015 / Frankfurter Neue Presse</span><br />DB Item #5</a></li> </ul> </div> </li> <li><a href="...">Main Nav Level #1 Item #2</a> <div class="dropdown"> <ul> <li class="headline"><a href="...">Level #2 Item #1</a></li> <li><a href="...">Level #3 Item #1</a></li> <li><a href="...">Level #3 Item #2</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #2</a></li> <li><a href="...">Level #3 Item #1</a></li> <li><a href="...">Level #3 Item #2</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #3</a></li> <li><a href="...">Level #3 Item #1</a></li> <li><a href="...">Level #3 Item #2</a></li> </ul> <ul> <li class="headline"><a href="...">Level #2 Item #4</a></li> <li><a href="...">Level #3 Item #1</a></li> <li><a href="...">Level #3 Item #2</a></li> </ul> </div> </li> <li><a href="...">Main Nav Level #1 Item #3</a> </li> </ul>

Now I am not sure how I could build this menue with the fuel_nav function.
Is this possible at all or should I better build an own module to construct my menue?

Comments

  • edited 4:00PM
    I'm not sure if you could get exactly what you have displayed but probably pretty close. For the text in some of the menu items, you can use a "pre_render_func" parameter for the fuel_nav function that would reference a custom function you create that generates the span and br for the text. This would only be recommended if it's not already processed to look that way (referring to the following):
    <span class="subline">17.03.2015</span><br />DB Item #1

    For the "class="headline" on the li, you can use the "styles" parameter for the fuel_nav function. This can be an array syntax that matches the nesting of your menu. For example, $styles[0][0] would reference the level 2 item 1 (0 indexed array).
    $styles[0][0] = 'headline'; echo fuel_nav(array('styles' => $styles));

    For dynamically generated menu items, you would need to use something like the "append" parameter for fuel_nav to insert extra menu items not found by default from the _variables/nav.php file.

    All the above would be parameters for the fuel_nav function. However, menu link attributes are controlled on a per menu item basis. So adding these classes:
    class="fancybox-gallery" rel="gallery_presse_menue"
    Would mean they would need to be added to the nav array as the attributes parameter:
    $nav['level2/item4'] = array('label' => 'Level #2 Item #4', 'attributes' => 'class="fancybox-gallery" rel="gallery_presse_menue"', 'parent_id' => 'level2');

    Here are some potentially helpful documentation and forum links:
    http://docs.getfuelcms.com/libraries/fuel_navigation#func_render
    http://docs.getfuelcms.com/general/navigation
    http://docs.getfuelcms.com/libraries/menu
    http://forum.getfuelcms.com/discussion/comment/7261#Comment_7261
  • edited 4:00PM
    Ok, I will try this soon, but I have another question...
    for selecting the dynamic menue items I should also use the pre_process function I think. correct? So I can keep the layout files clean of php code.
  • edited 4:00PM
    Probably. That function is there to help eliminate the need to enter in a lot of PHP code in your view files.
Sign In or Register to comment.