Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi all,

I successfully embedded a top menu snippet (menu-top.html) which looks like this:
Code: Select all
<li><a href="<cms:link 'about.php' />"<cms:if k_template_name=='about.php'> class="selected"</cms:if>>About</a></li>
<li><a href="<cms:link 'services.php' />"<cms:if k_template_name=='services.php'> class="selected"</cms:if>>Services</a></li>

I have almost the same menu at the bottom of the page, so I tried a second embed snippet (menu-bottom.html) but this time, each <a> has a class of "footerlinks". My head has become a little dizzy after some vain trials of getting this additional class into the above code.

This is my target code in the footernav that I want to achieve:
Code: Select all
<li><a href="http://mydomain.com/about.php" class="footerlinks selected">About</a></li>
<li><a href="http://mydomain.com/services.php" class="footerlinks">Services</a></li>

So, where in the embed snippet (menu-top.html) do I put the "footerlinks" class to make it my corresponding menu-bottom.html snippet?
Any help would be much appreciated!

Thanks.

Solaris
You could always just make a new snippet file for the bottom menu: menu-bottom.html
Code: Select all
<li><a href="<cms:link 'about.php' />" class="footerlinks<cms:if k_template_name=='about.php'> selected</cms:if>">About</a></li>
<li><a href="<cms:link 'services.php' />" class="footerlinks<cms:if k_template_name=='services.php'> selected</cms:if>">Services</a></li>

If you want to only use one snippet file for both menus, I'm sure we could come up with something.
Hi cheesypoof,
cheesypoof wrote: You could always just make a new snippet file for the bottom menu: menu-bottom.html

That's what I wanted to get across - please excuse my incoherent English at this nightly hour!
cheesypoof wrote:
Code: Select all
<li><a href="<cms:link 'about.php' />" class="footerlinks<cms:if k_template_name=='about.php'> selected</cms:if>">About</a></li>
<li><a href="<cms:link 'services.php' />" class="footerlinks<cms:if k_template_name=='services.php'> selected</cms:if>">Services</a></li>


Great, that's what I was looking for, thanks a lot!
Stupid me, in my trials, had added class="footerlinks" in front of <cms, just like you did, but forgot to delete "class" in front of "selected", so the output had "class" twice :oops:

If you want to only use one snippet file for both menus, I'm sure we could come up with something.

Well, it would be reallly interesting to see such a solution, if only in order to learn more about the many possibilities CouchCMS offers.

Thanks again for your kind help!

Solaris
Oh, well, I rejoiced too early, sorry :)
Just from looking at your above code made me think it was the perfect solution, but after trying it I see it doesn't work yet.
The code for the selected link comes out fine, but the other links are missing the closing quotes:
This is the faulty output:
Code: Select all
<li><a href="http://www.mydomain.com/about.php" class="footerlinks selected">About</a></li>
<li><a href="http://www.mydomain.com/services.php" class="footerlinks>Services</a></li>

See the missing quotes after the second footerlinks class?
So I still have the problem of accomodating links with 2 or more classes within the snippet.html.

So, further suggestions are very welcome!
Off to bed now, will check again here tomorrow ;)
Thanks!

Solaris
@solaris,
As far as I can see, cheesypoof's snippet works just fine.
Please review the code you are using. Probably the cut/paste resulted in introducing a typo.
@KK

You are right, my mistake :oops:
ATM, I only find time to test CouchCMC very late at night, so my concentration is not at its peak.
Nonetheless, I am making progress and am already in love with this CMS.

@cheesypoof

I apologize for my error, see above.
You've really got the hang of it, great :)
Yours is indeed the perfect code for a second embed snippet, and I even changed my top menu snippet accordingly, since it worked but your code is cleaner which also shows in Notepad++.

So thanks again to the two of you for your generous help - much appreciated!

Solaris
6 posts Page 1 of 1
cron