I went a different direction, where I created a channel, that will contain all of the main nav items. And I have fields in there that tells me what the channel name is, and I created a template with the following:
<ul> {exp:channel:entries channel=”main-nav” orderby=”entry_date” sort=”asc” dynamic=”no” } <li>{title}</li>
{embed="_embeds/sub-nav-items" entryid="{entry_id}"}
{/exp:channel:entries}
</ul>
which embeds the template below, but all I am getting is the parent level items, and not sure why that is the case.
<ul> {exp:channel:entries entry_id="{embed:entryid}” orderby=”entry_date” disable=”categories|member_data|pagination” dynamic=”off”} <li>{embed:entryid}</li> {/exp:channel:entries} </ul>
In you channel:entries loop inside of your embed, you’re using the entry_id parameter with the value of the parent-level entry. That would only return the single entry that has that entry_id.
I’d suggest you create a custom drop-down field that contains a list of your top-level entries, keyed on the url_title of the top-level entry. So let’s say you have the following entry structure:
Section A Page 1 Page 2
Section B Page 3 Page 4
Section C Page 5
I’d create a drop-down field with the following options:
section-a section-b section-c
These would match the url_title of the top-level entries.
Then I’d do the following in your templates:
<ul>
{exp:channel:entries channel=“main-nav” orderby=“entry_date” sort=“asc” dynamic=“no”}
<li>
{title}
{embed=“_embeds/sub-nav-items” parent=”{url_title}”}
</li>
{/exp:channel:entries}
</ul>And in the embed:
<ul>
{exp:channel:entries search:parent_entry=”{embed:parent}” orderby=“entry_date” disable=“categories|member_data|pagination” dynamic=“off”}
<li>{title} - {embed:parent}</li>
{/exp:channel:entries}
</ul>A word of warning though, this’ll get pretty messy with all of the DB queries, unless you’re caching.
[UPDATED: Actually, after reviewing what you said and what I was thinking… most of what I wrote above is probably not your best option. I’ll follow up with something better suited for your situation in a few minutes.]
So I was thinking of a situation where you’re treating the “content” entries channel as pages in a hierarchy, which might not be what you’re working with. After reviewing what you wrote, it looks like you’ve got the hierarchy spread into two channels–one channel contains the “content” entries, and another channel serves to group the entries into sections.
I think you might be better served by assigning categories to group the “content” entries, and use category tags to generate your navigation.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.