Conditionals

0 views
Skip to first unread message

insidertravels

unread,
Jun 21, 2009, 10:49:44 PM6/21/09
to habari-dev
Is there a way to use a conditional according to whether or not a post
has a certain tag attached to it? For instance, all posts tagged
"video" would execute the template snippet contained within the
conditional? This would be similar to how WordPress does if(in_category
('')) or if(has_tag('')).

Owen Winkler

unread,
Jun 21, 2009, 10:58:07 PM6/21/09
to habar...@googlegroups.com

All posts in Habari are Post object instances. The tags property of the
Post object is an array of tags that are associated to the post.

The key of the array is the tag slug, the value of the array is the tag
text.

So, to skip to the end:

if(isset($post->tags['my-tag'])) : // if the post has the tag "my-tag"


Owen

insidertravels

unread,
Jun 21, 2009, 11:05:01 PM6/21/09
to habari-dev
Cool! Thanks so much. That's exactly what I needed. =)
Reply all
Reply to author
Forward
0 new messages