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 menus and dynamic pages

August 23, 2007 11:41am

Subscribe [2]
  • #1 / Aug 23, 2007 11:41am

    ITCC

    32 posts

    I’m working on a practice site right now to become acclimated with EE.  The idea of a completely programmer-independent site (i.e. one that anyone can maintain easily once it has been coded) really appeals to me so I’ve been trying to make things as simple as possible.

    On my practice site, I have one main index page.  On this page is a menu of sorts that links to the respective pages.  The code is as follows:

    {exp:weblog:entries weblog="articles" orderby="menu_item" sort="asc"}
    {article_url}
    {/exp:weblog:entries}

    The code on my “articles” template is:

    {exp:weblog:entries weblog="articles"}
    {synopsis}{main}
    {/exp:weblog:entries}

    So, a menu item (link) is dynamically generated for each weblog entry in the weblog “articles”.  This works great and allows me to have multiple pages running off just one template.  It also allows a user to create a new page as well as a corresponding menu item, complete with link.  Definitely what I’m going for. 

    However, what I’d like to do is have the complete menu on all the pages generated by the “articles” template and weblog.  Using the same code as above, the “menu” that is generated on each “articles” page consists only of the link to the current page.  This makes perfect sense since the rest of the content on the page is limited to one weblog.  My question is: is there a way to include the full menu generated on the static home page on the generated pages?  I know I could hardcode the menu and use it as an {embed}, but I really like how easy it is to update it in its current form.  Any help would be appreciated.  Thanks!

  • #2 / Aug 23, 2007 2:21pm

    PXLated

    1800 posts

    More than likely it’s this…add dynamic=“off” to the weblog:entries tag. This tells EE to ignore what’s in the URL and just use what you have specifically specified in the tag. EE does a lot of things automatically by reading the URL, this sidesteps that.

  • #3 / Aug 23, 2007 2:37pm

    ITCC

    32 posts

    Thanks for the feedback!

    When I turn dynamic to “off”, my articles page shows every weblog entry regardless of which link.  I also tried enclosing the menu embed tag in its own weblog tag with dynamic set to “off”; this made the right number of links appear, but they all were links to the current page.

    Also, it seems like I want the page to be dynamic, just not one part of it.  Not sure if this is possible though.

  • #4 / Aug 23, 2007 2:38pm

    Lisa Wess

    20502 posts

    I’d recommend reading through The Importance of Semantics to get an understanding of what is going on here. =)

  • #5 / Aug 23, 2007 3:24pm

    ITCC

    32 posts

    Thanks, Lisa.

    I spent a good number of minutes racking my brain and typing up this response and naturally, while typing the very last sentence, I had an epiphany which solved my problem.  I was using an embedded menu template and it didn’t occur to me to only turn “dynamic” to off in this template.  Anyways, this gave me what I wanted.  Phew.  I’m going to go ahead and post what I wrote anyway.  Maybe it will be useful to someone and some point.  Also, it’ll make me feel better about wasting my time writing it :shut: !  Thanks!

    I think I can (try…heh) to clarify:

    1) I have a main index page.  On this page, I have the code to generate a menu from a specific field of my main weblog (a text-input called “article_url”):

    {exp:weblog:entries weblog="articles" orderby="menu_item" sort="asc"}
    {article_url}
    {/exp:weblog:entries}

    These links (generated) point to the article template (also generated), which prints the additional weblog fields for whatever weblog entry was referenced in the previously-clicked-on-link.

    This is what I intend for it to do, and I understand what I did to single out one entry.  However my problem is that:

    2) I would like to have the menu that is generated on the static main image page appear on the dynamically generated pages.  As is, each articles page, since it dynamically singles out only one weblog entry, has only one value for “articles_url” to tell the menu code to print.  Thus, my fancy dynamic-menu code doesn’t work on these pages.  Is this any clearer than before?  :red:

  • #6 / Aug 23, 2007 3:30pm

    Lisa Wess

    20502 posts

    Glad you got it worked out!  I’d recommend reading the other articles in that series (and behind the curtain) as they may lead to a better understanding before you start building. =)

  • #7 / Aug 23, 2007 8:04pm

    PXLated

    1800 posts

    Glad you got it working.
    The key is when you want EE to do its thing automatically (based on th eurl) you leave it on (default). When you want EE to do something different you use “off” and specify everything you need manually. On some templates you’ll use one or the other, on others both, depending on what the page and content are. To get the most out of EE it’s critical to understand how EE uses the URLs and how you can use the various segments.

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

ExpressionEngine News!

#eecms, #events, #releases