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.

Expandable category navigation & entry pages

October 08, 2009 8:18am

Subscribe [2]
  • #1 / Oct 08, 2009 8:18am

    lithiumdave

    215 posts

    Hi all. This is an age-old problem that I feel sure there must be a solution.

    Quick version: is there a way to trick EE into thinking it’s on a category page, whilst showing a single entry?

    Full version:

    I have a vertical category navigation which displays a list of categories, linking to their respective category pages. Child categories are set to auto-assign to their parent.

    Here’s the code:

    {exp:weblog:categories weblog="products" style="nested" show_empty="yes" }
        <a href="http://{path=products/index}">{category_name}</a>
    {/exp:weblog:categories}

    Basic stuff so far.

    There are a couple of levels of nested categories and I want the nested subcategories only to show when a parent is clicked. I’m using Silenz’s Category Expander plugin to achieve this, and it works great on category pages which have a category URL.

    I need the ‘opened’ nested state of the navigation to remain open, regardless of whether I’m on a category page or have clicked through to a single entry, in order to maintain the ‘current’ state of the navigation.

    Of course, if I click through to view any weblog entries (viewed on an entry page with an entry title in the URL) then obviously the category navigation breaks, or at least collapses back to showing just parent categories again. I totally understand why.

    Question is: is there a clever way I can somehow display a single entry, whilst still tricking EE into thinking it’s on a category page? If I can do that, the category navigation will stay open AND I’ll be able to display a single entry.

    I’ve considered messing about with URL segments but each time I try to add a segment to a category URL page categories break.

    Thanks so much for any help or advice.

    Dave

  • #2 / Oct 09, 2009 12:52pm

    lebisol

    2234 posts

    But how would you handle those entries that belong to more than 1 category? There is no way to ‘mark’ selected category because user could click/select either one of the categories….
    unless you use sqlquery to filter categories based on entry id/title pulled from url segment(s). In return, you may have to create cat list also using a query…
    perhaps silenz can help out… 😊

  • #3 / Oct 09, 2009 12:55pm

    lithiumdave

    215 posts

    In this case actually the client will only ever be assigning an entry to 1 category. Unless of course you mean that I have children auto-assigning to parents, in which actually yes, an entry could feasibly be in 3 categories… I see what you mean!

    I’ll have a think about how a sqlquery might work. I’m tempted to go with hard-coding the category tag as linear style, using nested conditionals, rather than the automatic nested category style with the plugin. Lots more work but might be the only way to go here.

    Thanks for your help.

  • #4 / Oct 09, 2009 1:21pm

    lebisol

    2234 posts

    Yeah it is more work but doable with conditions as you said it…post back if you get stuck with the query.

  • #5 / Oct 09, 2009 1:22pm

    lithiumdave

    215 posts

    I will, thanks.

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

ExpressionEngine News!

#eecms, #events, #releases