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