We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Tome Module Navigation Help

Development and Programming

james Brown's avatar
james Brown
492 posts
17 years ago
james Brown's avatar james Brown

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;
}
       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

One method (which is quite inelegant, but I’m currently using as quickie) is to query the database directly and get the ID (= page number).

So wrap your {exp:static_page_page} with an {exp:query parse="inward"} to retrieve the ID.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Sam, I’m not very familiar with using exp:query – can you give an example of what the actual code would look like to retrieve the id as you’ve described?

       
Sam C's avatar
Sam C
16 posts
17 years ago
Sam C's avatar Sam C

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.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

Thanks! I’ll give that a go.

       
Eric Barstad's avatar
Eric Barstad
198 posts
17 years ago
Eric Barstad's avatar Eric Barstad

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!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.