Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a multi-level navigation bar with the ExpressionEngine's Structure add-on?

I am working with ExpressionEngine and the Structure add-on latest versions.

I am looking for some help on generating a 4 items nav bar, where two items are in a different Structure level.

My Structure rows look like this:


Services (parent)

-----Translation (child)

-----Videos (child)

Studio (parent)

About us (parent)


And my main navigation bar should be:

Translation - Videos - Studio - About us

As you can see they are at different levels. I've been working for hours trying even with Structure Entries add-on, but I simply cannot find a way to generate this navigation.

I'd appreciate any help you can give me.

like image 644
Sergio Acosta Avatar asked Nov 01 '12 18:11

Sergio Acosta


2 Answers

Structure ultimately stores its 'pages' as regular EE entries, so you could just hardcode the entry ID's into a channel:entries loop to grab the titles:

<ul>
{exp:channel:entries dynamic="no" entry_id="3|4|6|12" disable="categories|pagination|member_data"}
    <li><a href="{page_uri}">{title}</a></li>
{/exp:channel:entries}
</ul>

Alternatively if you want to give the client complete control of what appears in the navigation you could set up a custom checkbox field for 'show on primary nav' and then use something like this:

<ul>
{exp:channel:entries dynamic="no" search:options="=show on primary nav?" disable="categories|pagination|member_data"}
    <li><a href="{page_uri}">{title}</a></li>
{/exp:channel:entries}
</ul>

(would be a bit nicer using P&T Checkboxes instead of the crappy built-in ones.)

No offence to the Structure module but it's this kind of thing that would really make me use Nav-EE instead, or, more often I would opt for an entirely hardcoded top level nav... The client usually thinks they need full control but in reality that top level navigation is seldom going to change (and when it does the chances are they'll need you to do other work on the site anyway!).

like image 188
James Smith Avatar answered Sep 27 '22 22:09

James Smith


You are looking for Structure Entries: http://devot-ee.com/add-ons/structure-entries (which is free!)

like image 28
Denver Sessink Avatar answered Sep 27 '22 22:09

Denver Sessink