Forum
Using variable within conditional (if) in a template
Dear Perchers,
I would like to display the year of a post only if it is different from the current year. What I tried did not work:
I included this in the post listing page:
PerchSystem::set_var('currentYear',date('Y'));
perch_blog_custom(array(
'sort'=>'postDateTime',
'sort-order'=>'DESC',
'template'=>'blog/post_in_list.html',
));
... and this in the blog post template (post_in_list.html):
<perch:if id="postDateTime" format="Y" value="<perch:blog id="currentYear" />" match="neq"><perch:blog id="postStartDate" format="Y" /></perch:if>
I would be grateful for any advice on how to solve this.
Thanks a lot in advance,
Laszlo
This should work: