ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Dynamic subpage navigation

December 05, 2009 7:27pm

Subscribe [2]
  • #1 / Dec 05, 2009 7:27pm

    webdezzo

    16 posts

    Ok all, I have really been racking my brain on this one as I am really excited about EE2 and trying to learn the proper way to structure what I am trying to do.  So bare with me!

    I have a site that will have main navigation that will be static for the top level navigation and under each top level item, it will list sub pages that I want to be dynamic. Like so:

    Main Section 1
    -> Sub Main Section 1
    -> Sub Main Section 2
    
    Main Section 2
    -> Sub Main Section 1
    -> Sub Main Section 2

    Etc.  I want to use 1 “subpage” template that embeds a sub navigation template in it.  This subpage template will be the template that all sub pages use as they do not change.

    If I click on main section 1, I want the sub nav to display all of the sub main sections and nothing else.

    Sounds simple? ehem.  I understand (I think) the concept of how it should work, and I do this all the time in CodeIgniter, I just think I am missing something in the picture doing this within EE2. 

    I am using the pages module, and in each page that I add, I add the Pages URI like so:

    /main_section_1/  (root page of section)
    /main_section_1/sub_main_section_1/
    /main_section_1/sub_main_section_2/

    Etc.  The templates main links are hard coded using the ee paths etc.  So I can get to http://localhost/sitename/index.php/main_section_1/ just fine.  I can also get to http://localhost/sitename/index.php/main_section_1/sub_main_section_1/  just fine as well (using nested urls). 

    The problem is getting the subnav to only display pages that belong to it’s section and not displaying the root /main_section_1/ in the sub navigation.

    My subnav should only output the 2 subpages.  I have tried categories and everything else and just cannot seem to get it to work.  What is the best way to handle this?  I really don’t want to have a channel for each “main section” and really don’t want to have a template group setup for each main section either.

    Am I going about this wrong?  Thanks in advance for any help you all have to offer!

  • #2 / Dec 06, 2009 12:27pm

    Focus Lab Dev Team

    1129 posts

    Unfortunately the Pages module isn’t built to provide this (as you’ve discovered)

    Fortunately there’s a fantastic module called Structure which is like Pages on crack. It’s a commercial module but worth every penny. It has a tag that spits out sub_nav dynamically for you. Check it out at buildwithstructure.com

  • #3 / Dec 06, 2009 3:28pm

    webdezzo

    16 posts

    Hey Erik!

    I actually have checked it out, and played with it before on EE 1.6 - but I am currently trying to get this to work with EE 2.0 - and Structure EE2 compatibility is looking at sometime in March 2010.

  • #4 / Dec 06, 2009 4:10pm

    Focus Lab Dev Team

    1129 posts

    I actually have checked it out, and played with it before on EE 1.6 - but I am currently trying to get this to work with EE 2.0 - and Structure EE2 compatibility is looking at sometime in March 2010.

    Ah that would be a problem then. If you find a way outside of structure to do what you need I’d be very interested to learn about it. 😊

  • #5 / Dec 06, 2009 5:59pm

    webdezzo

    16 posts

    Victory is mine!

    So I figured out a way based on a lot of reading, a lot of trial and error and just plain not knowing what I am doing quite yet with EE2.  It’s funny because the phrase “you’re thinking to hard” came up on many of the tutorials etc that I read through.  And they are right. 

    Templates are key.  I was trying to use one generic “subpage” template and run everything through that.  What I ended up doing is creating a channel for each sub section with a template that embeds a different subnav template for each section.  Then just populate the subnav based on the channel that is using that template.

    So the about section has an about channel and an about template that uses an about subnav.

    Seems to work really well!

  • #6 / Dec 06, 2009 10:04pm

    Focus Lab Dev Team

    1129 posts

    Victory is mine!

    Seems to work really well!

    Great! Thanks for sharing what you did.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases