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.

Menu Management

July 10, 2007 5:16pm

Subscribe [0]
  • #1 / Jul 10, 2007 5:16pm

    c@sey

    40 posts

    Hi,

    I’m fairly new to EE and am curious - What are the best practices of implementing menu systems such as navbars and such?

    I want the navigation to be global in my site but every time I add a menu item, I have to update 20 template files. Has something been left out?

  • #2 / Jul 10, 2007 5:26pm

    lerva

    45 posts

    A lot 😊

    If you want same navbar for every page, then you should make it Global variable. You have then only {navbar} in your 20 templates, and you have to update only one variable.
    http://expressionengine.com/docs/templates/globals/user_defined.html

    If you need some tags inside your navbar, then you should make it its own template and embed it.
    http://expressionengine.com/docs/templates/embedding_templates.html

    If you are speaking about dynamic menus, then that’s different case.

    I actually found EE:s default template a little bit misleading too. Default template is messy and not made in good practice. Ok, it’s maybe easy to understand, but if you follow it (like I think many people will), then you go to situation where you have 20 templates to update for one single task.

    Also in Overviews -> Features there is bad text about templates:

    # Full Page Modeling
    Each template represents an entire web page.

    That (and default template) made me think first, that EE really isn’t dynamic at all. Oh, I’m glad I was wrong.

  • #3 / Jul 10, 2007 5:50pm

    ms

    274 posts

    Using a global variable as a start is a good advise. A step beyond that would be using embed with a template only containing the menu code. The advantage is that you can pass variables via embed, which you can’t using a global variable. Passing variables to an embed containing the menu code can for example be useful for highlighting the current menu option.

    See here and here

    HTH
    -Markus

  • #4 / Jul 10, 2007 6:00pm

    c@sey

    40 posts

    Thanks for the replies. That makes sense. I was going to do a manual PHP include but this seems to be more conventional looking into your suggestions. I’ll definitely use this advice. Thanks again!

  • #5 / Jul 11, 2007 8:12am

    medic119

    52 posts

    Personally, I use the embed method mentioned above.  It gives me a much broader control of the items i want in the menu as well as being easier to make use of conditionals and such(I have several items which only appear to certain user groups).

    I am a firm believer in doing as little work as possible for the biggest impact and the embed method is perfect.  I edit one template and it is propagated throughout the site.  In fact, most of my pages are simply embeds.  The column, menubar, etc are all embeds.  I segment up the page for each template so as much recurring data as possible is shifted to embedded templates.

    The current design also makes broad use of the IF, IF:Else, etc conditionals and segment variables so that I have one template that displays all my static info based on the particular segment shown.  Also the little gray “Your Here” box in the top left is a big if/then conditional. 

    This is the first time I relied so havily on segmenting/conditionals and combined with the heavy use of embedded templates, it makes maintenance a breeze.

    EE is so powerful it makes work fun!! lol.

  • #6 / Jul 11, 2007 8:40am

    lerva

    45 posts

    Both are good. You just need to know when to use which one:

    but when you do not need tags or PHP, Template Globals are much more efficient, and have a smaller footprint in the template markup itself.
    ...
    Make wise use of Template Globals and you’ll not only make your site’s development process feel easier (especially in team situations), but you will also benefit from the performance gains of using them instead of embeds wherever appropriate.

    That’s from EE blog by Derek Jones. Full entry here:
    http://ellislab.com/blog/entry/behind_the_curtain_part_two/

    Simplified: I have always embedded header, because I want title to be dynamic. But usually I have static footer, so it can be safely Template Global.

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

ExpressionEngine News!

#eecms, #events, #releases