yz10
yz10

Reputation: 731

Is this possible with Blogger's conditional tags?

Basically I want to do this with blogger's conditional tags. Is it possible?

if blog page type = item page
  if a label called 'test' exists
    <div class='test'>
  else
    <div>
  /if
/if

Upvotes: 0

Views: 888

Answers (1)

Zahhar
Zahhar

Reputation: 187

Depends on what you want to do, and where. So far as I'm aware, data:post elements are only accessible inside the <b:includable id='main'></b:includable> tags. Here's a little something that should help get you started:

<b:if cond='data:blog.pageType == &quot;item&quot;'>
  <b:loop values='data:post.labels' var='label'>
    <b:if cond='label.name == &quot;MY LABEL X&quot;'>
      <div>LABEL X specific content.</div>
    </b:if>
    <b:if cond='label.name == &quot;MY LABEL Y&quot;'>
      <div>LABEL Y specific content</div>
    </b:if>
  </b:loop>
</b:if>

At this time, the <b:loop ...>...</b:loop> method is the only way I know to get access to the individual label names. This is untested code, so you might need to fiddle with it.

Upvotes: 3

Related Questions