We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How do you get the parent level channels

Development and Programming

IrishManInUSA's avatar
IrishManInUSA
15 posts
14 years ago
IrishManInUSA's avatar IrishManInUSA

what is the best way to build out the site navigation dynamically, when I have each section of the site in its own channel?

       
Click Rain 1's avatar
Click Rain 1
9 posts
14 years ago
Click Rain 1's avatar Click Rain 1

A custom SQL query using the query module, explicitly excluding non-section channels?

I’m only half-joking.

       
IrishManInUSA's avatar
IrishManInUSA
15 posts
14 years ago
IrishManInUSA's avatar IrishManInUSA

hehehe…..much rather not have to do that. 😊

       
IrishManInUSA's avatar
IrishManInUSA
15 posts
14 years ago
IrishManInUSA's avatar IrishManInUSA

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>

       
Click Rain 1's avatar
Click Rain 1
9 posts
14 years ago
Click Rain 1's avatar Click Rain 1

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.]

       
Click Rain 1's avatar
Click Rain 1
9 posts
14 years ago
Click Rain 1's avatar Click Rain 1

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.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.