Page 1 of 1
[Solved] Changing CSS using an IF statement in a Menu
Posted: Thu Dec 11, 2008 5:49 am
by Frankie
I am using this bit of code to change the CSS and highlight that menu item if it is the currently loaded page:
Code: Select all
{if $page == "home"}<li><a href="/" class="on">Home</a></li>{else}<li><a href="/">Home</a></li>{/if}
My question is, how can I get the HOME menu item to be affected by the IF statement when "index.php?page=home" is not being used and it's just at the root ".com/'?
Thank you for the help, you coders are so much more talented than this wannabe dev designer

Re: Changing CSS using an IF statement in a Menu
Posted: Thu Dec 11, 2008 10:24 am
by Dee
I'm not sure if I understand the question completely.
If the page with alias 'home' is set as the default page, the menu item will be affected by the IF statement when you are on the homepage, whether it's called as index.php?page=home, domain.com/index.php or just domain.com/
Regards,
D
Re: Changing CSS using an IF statement in a Menu
Posted: Thu Dec 11, 2008 4:27 pm
by Nullig
The standard menu templates already highlight the active menu item.
Nullig
Re: Changing CSS using an IF statement in a Menu
Posted: Tue Jan 27, 2009 12:07 am
by Frankie
Solved. I used the page ID instead of the alias.
The main issue was that when I would use the root "/" as the URL on navigation CMSMS wasn't recognizing the alias "home" as being loaded (since index.php?page=home wasn't being used)...changing my value to the page ID solved this problem. Thanks for responding!
Below was the easy solution to this problem!
Code: Select all
{if $page == "15"}<li><a href="/" class="on">Home</a></li>{else}<li><a href="/">Home</a></li>{/if}
Re: [Solved] Changing CSS using an IF statement in a Menu
Posted: Wed Jan 28, 2009 7:31 pm
by Dr.CSS
If you would have looked thru the default install pages you would have seen that every menu template that comes with it has a currentpage type in them so you can target the current page to be styled your way, you don't have to do all that you do now to get what you need...