This is third in the series of the three tutorial for Blogger Template and deals mainly with the explanation of the expr: namespace and understanding its usage. The other tuts are:
- Blogger Template Explanation - Sections, widgets, includables, includes. b: namespace
- Blogger Template Explanation - Data access. data: namespace elements.
- Blogger Template Explanation - How to use expr: namespace - customize links.
Expr namespace is simple but its usage is very important. Expr is basically used in conjuction with data tags. For making the blogger engine aware that the xml tag attributes coming next are having data tags in them and have to be parsed. Whenever there is a tag say anchor tag, you will have attributes like href and in that case you want the href link created dynamically with help of some data say data:post.url then you will have to use href as expr:href.
Simple implementation of expr:href in the title includable.
This includable is the title section of your blog. Check the usage of expr:href with the anchor tag.
<b:if cond='data:blog.url == data:blog.homepageUrl'>
See this code below for understanding the implementaion of expr:src and over other such tags. It is being used for parsing the data tags in image img tag attributes.
<a expr:href='data:blog.homepageUrl' style='display: block'>
As you can see how expr tag is applied to the attributes selectively. Wherever data was to be used expr is applied and in style where data tag is not required the expr is ommitted. Therefore the expr namespace variables are all the attributes which might have some data namespace variable inserted in it. So use expr for data tags used in any attribute values like expr:title, expr:id, expr:onClick and so on. These attributes can be for any xml tag. I have seen it in anchor a, image img, span, div, select, input, button etc., so pretty much everything.
Example Social Bookmark StumbleUpon button for Blogger.
This code listing below explains how to insert stumble upon button for blogger. Although it serves as an example on how to do this but my main focus here is on the usage of quotes. So check how the single and double quotes are used in expr:href for creating and using the url to submit and/or thumbs up the specific post correctly. It generally does not matter that you are using single or double quotes, but when your attribute has to use both of them single quotes decide the attribute opening and closing and double quotes are understood as part of attribute.
expr:href='"http://www.stumbleupon.com/submit?url=" + data:post.url + "&title=" + data:post.title'
Example Social Bookmark - Add Digg to Blogger
digg_url = '<data:post.url/>';
digg_skin = 'compact';
digg_window = 'new';
<div class='post-footer-line post-footer-line-3'>
<b:if cond='data:blog.pageType != "item"'>
<b:if cond='data:post.numComments == 1'>
This comes to the end of the three tutorials which I was intending to write on the blogger template. But If you want anything else to be added in this tutorial series let me know and I will do it.
If you have done anything interesting with the blogger template create a back-link to it in this tutorial. Please share you comments about the things discussed and add information that you feel will benefit others. Thanks for reading.