Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Working on my menu and it's not recognizing the class, or not loading the class and I'm trying to figure it out.

My template for instance is named about and I have the link the header.html listed as

Code: Select all
<li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='About'>class="current"</cms:if> >Home</a></li>


However, the first part where it links the cms:link shows up. The if statement doesn't recognize though.

My CSS is stated as:

Code: Select all
ul#menu1 li a.current{
color: red;
font-weight:bold;
}


Any idea? Is it the CMS not loading the if statement? I've tried everything css wise. Nothing is happening. Thanks!
Hi,

I think you are not specifying the right value for the template name.
The variable k_template_name will always have a '.php' in it e.g. I think the name of your 'About' template should be 'about.php' and not 'About' (which would be the template's title - not name).

When in doubt about any variable you can use
<cms:dump /> or <cms:dump_all /> to see their actual values.

Hope this helps.
Thanks kk, will try that now.
KK wrote: Hi,

I think you are not specifying the right value for the template name.
The variable k_template_name will always have a '.php' in it e.g. I think the name of your 'About' template should be 'about.php' and not 'About' (which would be the template's title - not name).

When in doubt about any variable you can use
<cms:dump /> or <cms:dump_all /> to see their actual values.

Hope this helps.



KK,

I did this to the folders and .php files that it should link to. It's still not working.

Code: Select all
<li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='index.php'>class="current"</cms:if> >Home</a></li>
     
        <li><a href="<cms:link 'port/portfolio.php' />" <cms:if k_template_name=='portfolio.php'>class="current"</cms:if> >Portfolio</a></li>   
   
        <li><a href="<cms:link 'blog/blog.php' />" <cms:if k_template_name=='blog.php'>class="current"></cms:if> >Blog</a></li>   

        <li><a href="<cms:link 'contact/contact.php' />" <cms:if k_template_name=='contact.php'>class="current"</cms:if> >Contact</a></li>


any idea?
You are supplying the template names to the cms:link tags.
You should use the same values for checking for the current template also.
From what I can see, the names of your templates are 'port/portfolio.php', 'blog/blog.php' and 'contact/contact.php' (seems you have placed them in folders). Your code should actually be -
Code: Select all
<li><a href="<cms:link 'index.php' />" <cms:if k_template_name=='index.php'>class="current"</cms:if> >Home</a></li>
     
        <li><a href="<cms:link 'port/portfolio.php' />" <cms:if k_template_name=='port/portfolio.php'>class="current"</cms:if> >Portfolio</a></li>   
   
        <li><a href="<cms:link 'blog/blog.php' />" <cms:if k_template_name=='blog/blog.php'>class="current"></cms:if> >Blog</a></li>   

        <li><a href="<cms:link 'contact/contact.php' />" <cms:if k_template_name=='contact/contact.php'>class="current"</cms:if> >Contact</a></li>
RESOLVED. I had to add the folder extensions as well.

<li><a href="<cms:link 'contact/contact.php' />" <cms:if k_template_name=='contact/contact.php'>class="current"</cms:if> >Contact</a></li>

It's now showing correctly.
6 posts Page 1 of 1
cron