Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
Hello, hello!

I want to do something very simple, same as it is done in the documentation example, and have no idea why it is not working..

It is about simple menu (list and css), which I saved as a snippet, and all works well except that I cannot get the the CSS style for the active link/page to work. And class="active" style is supposed only to change background color, nothing else….

I started with using exactly the same code from Aurelius page, which goes like this:

<li >
<a href="<cms:link 'index.php' />">
<cms:if k_page_name=='index.php'>class="active"</cms:if>
<span class="bold">Home</span></a>
</li>



Would appreciate a lot an explanation, what do I do wrong....

thanks in advance

Tanja
Hi Tanja,

Following is the code used in the tutorial (snippets/header.html):
Code: Select all
<li>
   <a href="<cms:link 'contact.php' />" <cms:if k_template_name=='contact.php'>class="current"</cms:if> >
      <span class="meta">Get in touch</span><br />Contact Us
   </a>
</li>

I think you should test against 'k_template_name' (as in the snippet above) instead of 'k_page_name'.

Please use the code above and let me know if you still run into the same problem.

Thanks
Hello KK!

thanks for your great support!

for some to me unknown reason, it won´t work with this original code, that also you have quoted above, even when I choose k_template_name...

BUT, it is working with k_template_name for producing a css class name that i need

<li >
<a href="<cms:link 'index.php' />" class="<cms:if k_template_name=='index.php'>aktiv</cms:if>">
Home
</a>
</li>

thanks again!

tanja
I just wanted to add, that also first code you have posted works ....

I have just realized that I have messed up the code quiet a lot initially, and started to believe that this part
<cms:if k_template_name=='contact.php'>class="current"</cms:if>
comes outside of <A> tag :oops:
I am glad you managed to get it working :)
All those nested tags do make it a little confusing to look at.
I personally find that editors like Notepad++ that highlight the tag pairs when you click on any are very handy in navigating through unfamiliar code.
5 posts Page 1 of 1