Answers.Body: <p>The <code>craft_structureelements</code> table contains the data you need to determine the exact position &amp; level of each entry in your structure. But you'd need some fancy plugin logic to attack that data and use it to your advantage.</p>
  
  <p>In all honesty, I really feel like you're going the wrong way on this, and you're better served trying to find a way to make the <code>slug</code> or <code>id</code> work for you. The sole purpose of a slug is to identify a specific page.</p>
  
  <p>How about this...</p>
  
  <p>When you dynamically generate your nav, add a CSS class with slug of that nav item. Then, you can verify that against the slug of the page which is being loaded. Even if the slug changes, it'll change in both places simultaneously.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-12T00:04:22.273Z
Answers.Text: Ah - brilliant! Your suggestion at the bottom on the slug was the ticket. Thanks so much!
Answers.UserDisplayName: dpayne
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-11T23:42:45.297Z
Answers.LastActivityDate: 2015-12-11T23:42:45.297Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>You're going to need some kind of context as to what is "current"; the context you have is in <code>craft.request</code> -- I'm not sure what else you'd use, other than slug / URL / getSegment logic.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-11T23:26:21.330Z
Answers.Text: Right, exactly what I'm struggling with. I provided some additional context for Lindsey D above if that helps.
Answers.UserDisplayName: dpayne
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-12-11T23:10:25.453Z
Answers.LastActivityDate: 2015-12-11T23:10:25.453Z
Answers.UserDisplayName: andrew.welch
Body: <p>I want to conditionally add some CSS to a subnav element if that page in the subnav is currently active. However, I can't add the CSS based on any slug / URL / getSegment logic, as that will likely be changed down the road. I also can't use the ID of the page. </p>
  
  <p>The pages in this subnav are part of the same structure and it seems to me the best way to set the rule would be based on the order of the page in the structure. Something like if page 2 in craft.entries.section('') is active then apply CSS to target element. </p>
  
  <p>Is this possible in Craft? If so, how would I do that? If not, other ideas for how to approach it?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-11T23:09:15.390Z
Comments.Text: Using the entry _position_ is possible, but sounds even sketchier than using a slug. Moving the entry within the structure would instantly break that. Is the entry nested below another entry? Can you use the ID of the _parent_ entry?
Comments.UserDisplayName: Lindsey D
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-12-11T23:23:52.610Z
Comments.Text: @LindseyD I have five entries under one parent. On all pages there is a subnav table with the six entries listed (including the parent). The subnav is ordered sequentially from left to right. The names in the subnav are set by the order of the entries. So if an entry moves from 2 to 3 in order, the 2nd & 3rd names in the subnav change. 
  
  I would like the active entry to be bolded in the subnav, regardless of its position in the table. However, if I set-up the logic to say bold this cell if the ID of the entry is xyz, and its position changes, the same cell is bolded but for a different title.
Comments.UserDisplayName: dpayne
Tags: <entries><conditional><order>
Title: Conditionally Applying CSS to Element on Active Page Without Using URL or ID Logic
ThreadText: # Conditionally Applying CSS to Element on Active Page Without Using URL or ID Logic
  
  (Asked by: username_0 on 2015-12-11)
  
  I want to conditionally add some CSS to a subnav element if that page in the subnav is currently active. However, I can't add the CSS based on any slug / URL / getSegment logic, as that will likely be changed down the road. I also can't use the ID of the page.
  
  The pages in this subnav are part of the same structure and it seems to me the best way to set the rule would be based on the order of the page in the structure. Something like if page 2 in craft.entries.section('') is active then apply CSS to target element.
  
  Is this possible in Craft? If so, how would I do that? If not, other ideas for how to approach it?
  
  **Tags:** entries, conditional, order
  
  > **Comments:**
  > **username_1**: Using the entry _position_ is possible, but sounds even sketchier than using a slug. Moving the entry within the structure would instantly break that. Is the entry nested below another entry? Can you use the ID of the _parent_ entry?  
  > **username_0**: @username_1 I have five entries under one parent. On all pages there is a subnav table with the six entries listed (including the parent). The subnav is ordered sequentially from left to right. The names in the subnav are set by the order of the entries. So if an entry moves from 2 to 3 in order, the 2nd & 3rd names in the subnav change.   I would like the active entry to be bolded in the subnav, regardless of its position in the table. However, if I set-up the logic to say bold this cell if the ID of the entry is xyz, and its position changes, the same cell is bolded but for a different title.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2015-12-11. Score: 2 | Accepted answer
  
  The `craft_structureelements` table contains the data you need to determine the exact position & level of each entry in your structure. But you'd need some fancy plugin logic to attack that data and use it to your advantage.
  
  In all honesty, I really feel like you're going the wrong way on this, and you're better served trying to find a way to make the `slug` or `id` work for you. The sole purpose of a slug is to identify a specific page.
  
  How about this...
  
  When you dynamically generate your nav, add a CSS class with slug of that nav item. Then, you can verify that against the slug of the page which is being loaded. Even if the slug changes, it'll change in both places simultaneously.
  
  > **Comments:**
  > **username_0**: Ah - brilliant! Your suggestion at the bottom on the slug was the ticket. Thanks so much!  
  
  ---
  
  ### Answer by username_2 on 2015-12-11. Score: 1
  
  You're going to need some kind of context as to what is "current"; the context you have is in `craft.request` -- I'm not sure what else you'd use, other than slug / URL / getSegment logic.
  
  > **Comments:**
  > **username_0**: Right, exactly what I'm struggling with. I provided some additional context for username_1 above if that helps.  
  
  ---
  
  