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.

Highlight selected parents and children in categorial sidemenu

September 24, 2007 11:58am

Subscribe [4]
  • #1 / Sep 24, 2007 11:58am

    ombotron

    8 posts

    Hi there. I’m quite new to both EE and PHP. I’m about to program a three-level-menu site, where I hardcoded the first level in the index files of the different template groups (e.g. »Services« / »About us« and so on).

    Both the second and the third level run with the cat_expand-plugin, category groups corresponding to the first level menu items with their (sub-)categories assigned to weblog entries.

    The first level is hardcoded, because it’s horizontal on the top of the page and the two other levels are on the left side which doesn’t work with the plugin. This is not such a big problem because the different first level menu items have to have their designated templates anyway.

    3-level-expanding-menu

    To highlight the first level is no problem because it’s hardcoded, but how should I do this on the other two levels? The plugin serves a certain »active-style«-command, but that only wraps a div around the a-tag and can’t include a CSS-class to the a-tag and also it does this only for the present (sub-)category, but not its parent category. Should I rather change something in the plugin PHP or can I do this with some conditionals in the following template code? Or is the cat_expand_plugin the wrong way for this use in the first place? Creating new templates for every navigational state in all sublevels seems a bit unnecessary to me in a CMS …

    Thanks for any help!

    <div id="subnav">
    {exp:cat_expand:wrapper}
    {exp:weblog:categories root_node="8"}
    {exp:cat_expand:expander category="{category_id}"}
    <a href="http://{path=template_group}">{category_name}</a>
    {/exp:cat_expand:expander}
    {/exp:weblog:categories}
    {/exp:cat_expand:wrapper}
    </div>
  • #2 / Sep 25, 2007 6:31am

    ombotron

    8 posts

    Hi there again

    … Nobody any idea? I’d be really glad it there was any help, otherwise I’ll have to alter my template group structure to a unnecessary complex one. Or how else can I code a three-level navigation, where all three levels are highlighted, when I am on a subpage (top level on top of page horizontally, second and third level as hierarchical sidebar-menu)? I hardcoded the first level in different template groups and for the moment the second and third are categories and subcategories in category groups corresponding to the template groups.

    Am I totally wrong with this concept? Thanks for any ideas …

  • #3 / Sep 25, 2007 11:46am

    Robin Sowell

    13255 posts

    I’m just not familiar with the plugin, so I don’t know how to advise.  The best option would be to post to the writeup or hit the thread on it if there is one in the ‘Plugins’ forum.  (The css gurus might also have a sneaky way to do it- but css isn’t my forte.)

  • #4 / Sep 25, 2007 12:01pm

    ombotron

    8 posts

    I opened a thread in the plugins forum, maybe it is a better location for this question.

    Thanks anyway!

  • #5 / Sep 25, 2007 12:10pm

    silenz

    1651 posts

    The plugin serves a certain »active-style«-command, but that only wraps a div around the a-tag and can’t include a CSS-class to the a-tag and also it does this only for the present (sub-)category, but not its parent category.

    The reason the plugin cannot/will not modify the a-tag is that it has no idea whether there is an a-tag at all.
    Because whatever you put between {exp:weblog:categories} and {/exp:weblog:categories} is totally up to you. Therefore the plugin only offers the option to enclose whatever there is in between with some DIV’s that you can style.

    Should I rather change something in the plugin PHP or can I do this with some conditionals in the following template code? Or is the cat_expand_plugin the wrong way for this use in the first place?

    Hard to say without seeing what you are actually trying to do.

    The issue at hand is that when you are in a third-level category its second-level parent is not highlighted, did I get that right?

  • #6 / Sep 25, 2007 12:23pm

    ombotron

    8 posts

    Thanks for writing back!

    No, my problem is basically that neither the second nor the third level category is highlighted, because I always modify the css-styles of the navigation links via their a tag. So with the div-tag surrounding the a tag, my whole formatting concept is gone … Or is there a possibility to do it with conditionals, something like that (the example shown doesn’t work …)?:

    <div id="subnav">
    {exp:cat_expand:wrapper}
    {exp:weblog:categories root_node="10"}
    {exp:cat_expand:expander category="{category_id}"}
    <a href="http://{path=template_group}class=selected">{category_name}</a>
    {/exp:cat_expand:expander}
    {/exp:weblog:categories}
    {/exp:cat_expand:wrapper}
    </div>

    But in the meantime I already faced a new problem: even when i change the subnavigation root node in the different template groups, it somehow always shows the same subnavigation … Has this something to do with the assigned weblogs?

    Thanks for further help!

  • #7 / Sep 25, 2007 5:05pm

    silenz

    1651 posts

    {exp:weblog:categories root_node="10"}

    There is no parameter named root_node.

  • #8 / Sep 25, 2007 6:48pm

    ombotron

    8 posts

    Yeah, you’re right. I forgot to delete the root_node-parameter, which was a remaining part of me trying to combine your plugin with the subcategories-plugin … which of course didn’t work, that’s why I hardcoded the navigational first level in the template groups.

    Ok, but now how can I assign the expander-plugin to different category groups and in that way change the submenu items?

  • #9 / Sep 25, 2007 7:02pm

    e-man

    1816 posts

    my problem is basically that neither the second nor the third level category is highlighted, because I always modify the css-styles of the navigation links via their a tag. So with the div-tag surrounding the a tag, my whole formatting concept is gone

    What if you change line 115 of pi.cat_expand.php :

    return "<div >".$TMPL->tagdata."</div>";

    to this:

    return "<div  class=\"active\">".$TMPL->tagdata."</div>";

    then you can apply the style rules you are now applying to a to div.active a.
    Just my 2c.

  • #10 / Sep 25, 2007 7:29pm

    ombotron

    8 posts

    Thanks for that one, e-man!

    It works now for the present (sub-)category page, but not for its parent category like this example shows:

    – category_parent1
    category_parent2
    ––– subcategory1
    ––– subcategory2
    ––– subcategory3
    – category_parent1

    Maybe I’ll have to find a different way for a total solution … Because the problem of assigning the correct category groups to this sidebar-menu is still an open one.

    Thanks!

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

ExpressionEngine News!

#eecms, #events, #releases