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

CSS class in {snp_main_nav}

How Do I?

Claus's avatar
Claus
35 posts
2 years ago
Claus's avatar Claus

… <ul> <li><a{if segment_1 == ''} class=”nav”{/if} href=”{homepage}”>Home</a></li> <li><a{if segment_1 == 'about'} class=”nav”{/if} href=”{path='about'}”>About</a></li> <li><a{if segment_1 == 'blog'} class=”nav”{/if} href=”{path='blog'}”>Blog</a></li> <li><a{if segment_1 == 'contact'} class=”nav”{/if} href=”{path='contact'}”>Contact</a></li> <li><a{if segment_1 == 'testing'} class=”nav”{/if} href=”{path='testing'}”>Testing</a></li> <li><a{if segment_1 == 'testing_2'} class=”nav”{/if} href=”{path='testing_2'}”>Testing 2</a></li> </ul> …

The class=”nav” is only assigned to the very last entry in the list. How is that possible? I want to create a class for the links in the menu.

Claus

       
Jared Chesebro's avatar
Jared Chesebro
15 posts
2 years ago
Jared Chesebro's avatar Jared Chesebro

The nav class will only be applied when the condition of your if statements are met.

What you have:

<li>
    <a{if segment_1 == 'testing_2'} class="nav"{/if} href="{path='testing_2'}">Testing 2</a>
</li>

To always add the nav class you need to remove the if statement all together.

       
Claus's avatar
Claus
35 posts
2 years ago
Claus's avatar Claus

Hi Jared,

I inserted the line you posted exactly as it was, but then {title} and {page_content} are not being rendered anymore.

Claus

P. S.: Btw, how did you manage to include this code excerpt here with formatting and highlighting?

       
Rob Allen's avatar
Rob Allen
3,105 posts
2 years ago
Rob Allen's avatar Rob Allen

Claus, when you post click the link “Use Markdown for rich formatting.”, that will give you formatting options.

       
Claus's avatar
Claus
35 posts
2 years ago
Claus's avatar Claus

{exp:channel:entries channel="einfuehrung" limit="1"} <h4> {if page_heading} {page_heading} {if:else} {title} {/if} </h4> {page_content}

doesn’t work anymore.

       
Claus's avatar
Claus
35 posts
2 years ago
Claus's avatar Claus

Jared,

the code you gave me contains errors:

<li><a href="http://{path=%27testing_2%27}%22class=%22nav{if" class="nav{if"><b>T</b>esting 2</a></li>

       

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.