Customizing posts based on label in Blogger
Like to give different looks to different posts filed under different labels??  

replace the second occurrence of <data:post.body/> (between span attribute) with this



<b:if cond='data:post.labels'>
<b:loop values='data:post.labels' var='label'>
<b:if cond='data:label.isLast == "true"'>
<!-- Only using the last label -->
<div expr:class='"label" + data:label.name'>
<p> <data:post.body/> </p>
</div>
</b:if> 
</b:loop>
<b:else/>
<div class='labelNone'> <p><data:post.body/></p> </div>
</b:if>

Then In the style portion of your template, apply a style by specifying the div class. Here's an example that will put a background image for all posts with label "tech":


<style type='text/css'>
div.labeltech {
background-image: url(&quot;http://yoursite.com/Wallpaper-Widescreen.jpg&quot;);
background-repeat: no-repeat;
background-position: bottom right;
display: block; 
}
</style>
You can add your own styles inside the div.labeltech {HERE}

The only downside  is that as the label is defined only for the post wrapper , we cannot customize outside it with this trick.

If you need any clarifications, feel free to comment :) 

Reviews:

Post a Comment

BLOGGER SIZZLE © 2014 - Designed by Templateism.com, Plugins By MyBloggerLab.com

Contact us

Powered by Blogger.