css - Expression Engine navigation and conditionals -
thanks in advance problem. it's expression engine site. i'm having trouble simple conditionals navigation, active state. have placed active color sate within styles; however, there appears problem "if statements" because when inspect element, render in code (the navigation embedded).
<nav class="group" role="navigation"> <ul id="nav" class="group"> <li class="first"><a {if segment_1 == ""} class="active" {/if} href="{site_url}"><strong>now</strong></a></li> <li><a {if segment_1 == "articles"} class="active" {/if} href="/articles/"><strong>articles</strong></a></li> <li><a {if segment_2 == "readings"} class="active" {/if} href="/book-readings/readings"><strong>books</strong></a></li> <li class="last"><a {if segment_2 == "readings"} class="active" {/if} href="/shelf/readings"><strong>shelf</strong></a></li> </ul> </nav>
try:
<nav class="group" role="navigation"> <ul id="nav" class="group"> <li class="first"><a {if "{segment_1}" == ""} class="active" {/if} href="{site_url}"><strong>now</strong></a></li> <li><a {if "{segment_1}" == "articles"} class="active" {/if} href="/articles/"><strong>articles</strong></a></li> <li><a {if "{segment_2}" == "readings"} class="active" {/if} href="/book-readings/readings"><strong>books</strong></a></li> <li class="last"><a {if "{segment_2}" == "readings"} class="active" {/if} href="/shelf/readings"><strong>shelf</strong></a></li> </ul> </nav>
just confirm, state:
they render in code
i had assumed meant of them, hence suggestion of wrapping variables in quotes , curly brackets. you're going have problems last 2 conditions matched together. if problem, solution compare both segments:
<li><a {if "{segment_1}" == "book-readings" && "{segment_2}" == "readings"} class="active" {/if} href="/book-readings/readings"><strong>books</strong></a></li> <li class="last"><a {if "{segment_1}" == "shelf" && "{segment_2}" == "readings"} class="active" {/if} href="/shelf/readings"><strong>shelf</strong></a></li>
Comments
Post a Comment