I am trying to create a semi-collapseable navigation using Mark Huot’s Tome module. I am most of the way there but stuck on one last detail. I know once I get this detail it will work. I have hard-coded the one variable I am trying to get and it works perfectly.
I have a category/page structure something like this: Main Category - category 1 – 1 sub category – 1 sub category 2 - category 2 – 2 sub category – 2 sub category 2 …etc…
I have a side sub-navigation that leaves off “Main Category” and outputs everything under it with this:
{exp:static_page_path direction="post" page="2"}<a href="http://{url_title}" title="{title}">{title}</a>{/exp:static_page_path}
That works fine. It outputs a nested list of all categories and sub categories. What I want to do is have something that works similar to a collapsing menu. So when I am on the page “category 1” (or any of the subcategories), all of the subcategories for category 1 are shown and all other categories have their subcategories collapsed.
I have worked out a solution for most of it but a need a little bit of help. What I do is output the full menu with the tag above. In the CSS I just set all nested <li> to display: none. This hides all subcategories but displays all categories. So now all that is left to do is set all items belonging to the selected categories subcategories to display:block. For this I set a css style in the head of the page, the idea is that I will generate a list of the subcategories as id selectors. The basic structure is listed below. The only part I need to know is how do I get the page number of the 2nd URL segment? So for a url like
www.domain.com/main_category/category/subcategory
how would I get the page number for “category” and insert it into the static_page_path tag?
{exp:static_page_path direction="post" nest="false" page="*URL_SEGMENT_2*"}
, #{short_name}{/exp:static_page_path}
{
display:block;
}
Hi Eric,
Can’t remember what I was thinking when I posted that now.
However, the following should work:
{assign_variable:tome_group_id="5"}
{exp:query="SELECT c.cat_id FROM exp_categories WHERE group_id={tome_group_id} AND cat_url_title='{seg_2}'" parse="inward"}
{cat_id}
{/exp:query}
Where: {tome_group_id} is the ID of the Category Group you’re using for your Tome pages. {seg_2} is the URL segment you want to get the category ID for
Caveat: Doesn’t filter by site_id so would need further clauses to work with an installation using the new multiple site manager.
Upon further reflection, I guess this isn’t exactly what I’m looking for. Instead of getting the ID, I just want to access some sort of {count} variable. I’ve started a new post that describes what I’m looking for in a bit more detail. Thanks for your help, though!
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.