Timeline for Conditional logic to add class for specific section entries
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 1, 2015 at 11:24 | comment | added | Steve Rowland | Actually, I've just figured it out and the following code works: {% set segment1 = craft.request.segment(1) %}{% if segment1 == 'blog' %}white-nav-bg{% elseif segment1 == 'our-work' %}white-nav-bg{% endif %} I'll update the question with the code that worked based on your answer | |
Oct 1, 2015 at 11:22 | comment | added | Steve Rowland | Thanks for the feedback Mark. So would I use the following to set each segment? {% set segment1 = craft.request.segment(1) %}{% if segment1 == 'blog' %}white-nav-bg{% elseif segment1 == 'ourWork' %}white-nav-bg{% endif %} | |
Sep 29, 2015 at 16:36 | comment | added | Mark Busnelli Jr | Let me know if you need more info | |
Sep 29, 2015 at 16:36 | comment | added | Mark Busnelli Jr |
You can use getSegments then call each segment the same just changing the segment number in the example I gave you.
|
|
Sep 29, 2015 at 15:41 | comment | added | Steve Rowland | Thanks, this worked. As Kaspar mentioned above, because it is in the _layout template this is a better approach. Is there a way to set multiple values in the 'blah' part? I'd like to do this for a few different sections. | |
Sep 29, 2015 at 15:39 | vote | accept | Steve Rowland | ||
Sep 16, 2015 at 21:05 | history | edited | Brad Bell♦ | CC BY-SA 3.0 |
added 10 characters in body
|
Sep 16, 2015 at 14:26 | review | Low quality posts | |||
Sep 16, 2015 at 19:14 | |||||
Sep 16, 2015 at 14:06 | history | answered | Mark Busnelli Jr | CC BY-SA 3.0 |