Forum for discussing general topics related to Couch.
3 posts Page 1 of 1
I can't figure out how to link to an archive view of the current year using the cms:link tag.
Code: Select all
<a href="<cms:link masterpage='myTemplate.php' year='<cms:date format='Y'/>' />">Latest Archive</a>
In this case, there's a problem with single quotes within single quotes, but everything else I've tried seems to run into problems and errors, too.

I know there are ways to use Couch tags and variables within Couch tags to provide dynamic content, but I often become befuddled when trying to do so. Besides this specific problem, I'm wondering if anyone can help me to understand the general protocols for using Couch tags within the parameters of Couch tags.
Hi,

You should use double quotes because you are setting one Couch tag's parameter using another Couch tag. The code will become -
Code: Select all
<a href="<cms:link masterpage='myTemplate.php' year="<cms:date format='Y'/>" />">Latest Archive</a>

This is explained in detail here - http://www.couchcms.com/docs/concepts/s ... eters.html

Hope this helps.
The link to the documentation was exactly what I needed.

I was partially getting hung up because I didn't want to put double quotes inside double quotes (href="..."). But I see now that starting from the inside Couch parses out each tag before passing the output up the chain. So there is no conflict with the quotation marks inside of nested tags.

Thanks!
3 posts Page 1 of 1
cron