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.

Setting up navigation in EE

July 08, 2008 4:44pm

Subscribe [9]
  • #1 / Jul 08, 2008 4:44pm

    Deron Sizemore

    1033 posts

    I’ve always just developed my own sites using EE and for all intents and purposes, the only dynamic aspect to my navigation menus is the active state of the button which I do using conditionals. I usually just have a template which holds the navigation html which I embed into the various templates of the site and when the navigation needs updated, I just update the embed template file.

    I’m wondering though, what are some other ways you’re developing a dynamic navigation? I’ve read Boyink’s tutorial where he outlines how to do a dynamic navigation bar based on a weblog (or multiple weblogs) and I like it but I wasn’t real sure how to do both dynamic links along with static links like a contact page (that may link to a separate template not a weblog entry).

    Any other great techniques out there that you all like to use when creating a navigation structure that easy for the client to update so that they do not have to get in and get their hands dirty with the html templates?

  • #2 / Jul 08, 2008 10:17pm

    Boyink!

    5011 posts

    Deron - did you see this entry?

    That’s how I mix in dynamic nav with things like contact pages.

  • #3 / Jul 08, 2008 10:32pm

    Sean C. Smith

    3818 posts

    Michael,
    I don’t understand that article at all. I don’t see how a weblog entry becomes navigation and is easier than just creating a new template and linking to it via template_group/template_name

  • #4 / Jul 09, 2008 8:49am

    Boyink!

    5011 posts

    Hey Sean -

    That article builds on a situation like this, where the left nav is generated by a weblog:entries tag (here’s the tutorial for that approach.

    In that approach each weblog entry becomes an item in the navigation.

    There is one template group - called “static”, and one template - the index template.

    The code generates navigation to individual entries by:

    <li><a href="http://{url_title_path=static}">{title}</a></li>

    So an entry with a url title of “our_locations” would get a link generated of:

    /index.php/static/our_locations/

    The index template gets used to show the content, and it since it’s limited by url_title will only show the content from the Our Locations post.

    So I have one weblog with multiple entries, the left-nav is being constructed dynamically by a weblog:entries tag looping through those entries, and the links are being fed to one template.  Add or remove pages from the nav by just publishing or removing entries from that weblog.

    With me?

    Now - in addition to the “regular” content in that section you want to add a contact form.

    You could just create the contact form, and manually add a link to it either on top of or on bottom of the left-column weblog:entries that’s building the left-nav.  But you want it sorted alphabetically so it shows up in the middle of the navigation.

    What to do then?

    This is were my article comes in.

    What I do is create the contact form in the same template group as the static content.  So the static template group now has two templates - index and contact.

    Then I create a dummy entry in the weblog that’s being used to build the left nav, and call it “contact”.  The key here is that the url_title of the entry match exactly the name of the contact template I just made.

    This is a dummy entry because the content will never be seen.  Here’s why -

    With the new contact entry posted, EE will loop through that weblog and build the navigation, and now it will run across the new contact entry.  It will build a link to it in the same manner as all the other entries in that weblog:

    /index.php/template_group/url_title/

    in this case it will be:

    /index.php/static/contact/

    And that link will be sorted in along with all the other links to the other entries - so:

    About Us
    Contact
    Our Locations

    Etc.

    Still with me?

    But here’s the the key to that link loading the new contact template, rather than the index template with the weblog’s contact entry contents.

    It’s all in the order in which EE looks to match URLs to backend items.  When EE encounters the link of:

    /index.php/static/contact/

    It will first look for templates that to match that URL.:

    /index.php/template_group/template/

    So in this case, even though the navigation is being generated by a weblog entry called “contact”, when you click the link EE is first looking for a template called “contact”.  Since there is one, EE will load it instead of the index template with the weblog’s contact post instead.

    Does that help?

  • #5 / Jul 09, 2008 1:59pm

    Joe Michaud

    154 posts

    Hi Michael, I don’t know if this helped any of the other readers…  but it sure helped me.  Thanks!

    Along these same lines, I’ve been wondering if there is a sensible way dynamically to generate a site/main navigation menu?  I suppose it would require a query (perhaps similar to the one used to generate an htaccess file for removing index.php) that would spit out list of the template groups and the templates each one contains - in accordance with the site structure, of course.

  • #6 / Jul 09, 2008 2:06pm

    Boyink!

    5011 posts

    I don’t usually try to do main navigation dynamically - usually for a business site that navigation model rarely changes as it reflects their business model.  An embedded template with a unordered list usually works fine.

  • #7 / Jul 09, 2008 2:10pm

    Deron Sizemore

    1033 posts

    Deron - did you see this entry?

    That’s how I mix in dynamic nav with things like contact pages.


    No, haven’t seen that one Michael. Thanks for pointing it out to me. Looks like it will be a big help. 😉

    I noticed you mentioned adding the static page hard coded into the nav menu outside of the weblog:entries tags. This seems to be the easiest method but for some reason I couldn’t get it to work last time. I may have to revisit that technique. As for putting static pages in the nav menu dynamically and in a certain order, this should work great! I’ll post back if I have any questions.

    Hi Michael, I don’t know if this helped any of the other readers…  but it sure helped me.  Thanks!

    Along these same lines, I’ve been wondering if there is a sensible way dynamically to generate a site/main navigation menu?  I suppose it would require a query (perhaps similar to the one used to generate an htaccess file for removing index.php) that would spit out list of the template groups and the templates each one contains - in accordance with the site structure, of course.

    So you’re wanting to build a nav menu dynamically based on what templates are inside of each template group? So basically you will have a new template for every page of the site? Is that correct?

  • #8 / Jul 09, 2008 2:15pm

    Deron Sizemore

    1033 posts

    I don’t usually try to do main navigation dynamically - usually for a business site that navigation model rarely changes as it reflects their business model.  An embedded template with a unordered list usually works fine.

    Hmmm, that’s interesting. Even when the people updating the site may not have a clue as far as html is concerned or even how to get into the backend to change the nav menu or find where to change it? I suppose they could just contact you to make the quick change though wouldn’t it be easier to allow them to do it?

  • #9 / Jul 09, 2008 2:18pm

    Boyink!

    5011 posts

    I don’t usually try to do main navigation dynamically - usually for a business site that navigation model rarely changes as it reflects their business model.  An embedded template with a unordered list usually works fine.

    Hmmm, that’s interesting. Even when the people updating the site may not have a clue as far as html is concerned or even how to get into the backend to change the nav menu or find where to change it? I suppose they could just contact you to make the quick change though wouldn’t it be easier to allow them to do it?

    That’s the point - if the main navigation is changing, the business model is changing, so they’d need me anyway to build out the new section that’s being added to the nav.

  • #10 / Jul 09, 2008 2:19pm

    Joe Michaud

    154 posts

    So you’re wanting to build a nav menu dynamically based on what templates are inside of each template group? So basically you will have a new template for every page of the site? Is that correct?

    Yes, I think we are saying the same thing.

    At the time that I first started exploring this issue I was very, very new to the world of web design (now I’m just “new”) and had just switched from Joomla to EE.  As you can probably imagine, it was a difficult climb.

    Now that I think through it again, a dynamic site navigation system is probably just an unnecessary performance sucker since they very rarely change.  Hmmm…

  • #11 / Jul 09, 2008 2:27pm

    Deron Sizemore

    1033 posts

    That’s the point - if the main navigation is changing, the business model is changing, so they’d need me anyway to build out the new section that’s being added to the nav.

    Yeah… good point. 😉 The more I think about it, the more I’m in agreement with Joe. I don’t really need the dynamic nature of a navigation menu. Not for the main site navigation anyway. I’ve always just done the hard coded embed way on my own sites but may be doing some freelance work here soon so I was looking for ideas to allow the client to update the nav if they so chose, but it’s probably best to go with an embed.

    At the time that I first started exploring this issue I was very, very new to the world of web design (now I’m just “new”) and had just switched from Joomla to EE.  As you can probably imagine, it was a difficult climb.

    I used Joomla for a short time when I was trying to figure out what CMS I wanted to go with for the long haul. Tried a ton of them and hated them all until I found EE. I think you’ll get the hang of it soon enough especially coming from Joomla. They may be better now, but a few years ago when I tried it, it seemed like a nightmare. 😉

  • #12 / Jul 09, 2008 2:46pm

    Joe Michaud

    154 posts

    I used Joomla for a short time when I was trying to figure out what CMS I wanted to go with for the long haul. Tried a ton of them and hated them all until I found EE. I think you’ll get the hang of it soon enough especially coming from Joomla. They may be better now, but a few years ago when I tried it, it seemed like a nightmare. 😉

    It has been over a year since I made that switch and have never looked back.  That was the beginning of a conscious decision to make a career change into web development (and eventually web application development).  My skills have grown many orders of magnitude since then and I feel extremely fortunate to have found ExpressionEngine, the company that created it, and the community that supports it.

    When I do, finally, go pro I will likely focus entirely on EE driven sites.  All the others I’ve tried seem rather primitive to me now and often not flexible enough to let me tweak the subtle things that turn good sites into great ones.

  • #13 / Jul 09, 2008 3:10pm

    Deron Sizemore

    1033 posts

    Yeah, I definitely agree with your sentiments!

  • #14 / Jul 09, 2008 8:29pm

    stinhambo

    1268 posts

    I don’t usually try to do main navigation dynamically - usually for a business site that navigation model rarely changes as it reflects their business model.  An embedded template with a unordered list usually works fine.

    Don’t you just hate when clients say they want ‘full control’ over their navigation?

    I like the way you phrased this and I’ll be using it in the future 😊

  • #15 / Jul 09, 2008 8:44pm

    Sean C. Smith

    3818 posts

    Does that help?

    That’s a lot clearer now. Thank you.

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

ExpressionEngine News!

#eecms, #events, #releases