Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hello all,

I am trying to modify the following menu code so that it applies the class "active" to the li, even if one of the sub-pages is selected:

<li
<cms:if k_template_name=='index.php'>class="active"</cms:if>
>

drop_down_menu.jpg
drop_down_menu.jpg (45.86 KiB) Viewed 905 times


My attempt is below, which does not work (for obvious reasons I'm sure).
I have tried to make the CMS check if any of the listed pages are the "current page" - if so, apply the class active.

<li
<cms:if k_template_name=='index.php' || 'telsa_home.php' || 'tesla_x_home.php' || 'bmw_home.php' || 'renault_home.php'>class="active"</cms:if>
>


Do I need to use an Array?


I would really appreciate any advice on this, seems like it must have been mentioned before, sorry I could not find the post.

Many thanks in advance.

Steve
Hi,

The correct syntax for <cms:if> would be this -
Code: Select all
<li
<cms:if k_template_name=='index.php' || k_template_name=='telsa_home.php' || k_template_name=='tesla_x_home.php' || k_template_name=='bmw_home.php' || k_template_name=='renault_home.php'>class="active"</cms:if>
>

Please check if this helps.

That aside, if 'nested-pages' were used to create the menu, Couch would have done this calculation (marking parent as active for any sub-page) for you automatically.
This has worked perfectly many thanks KK.

I will probably look to set up the menu using nested pages in the future so thank you for the advice.

Kind Regards

Steve
You are welcome :)
4 posts Page 1 of 1
cron