I wanted to have title like:
Post title - Blog title
After few tries and got a very important tag blog.pageName from Internet, I finally could make it happened. The official Blogger document Layouts Data Tags is not really helpful for this, it doesn’t mention about blog.pageName and the new pageType of pages static_page.
The following template code is what this blog is using:
<b:if cond='data:blog.pageType == "item"'> <title><data:blog.pageName/> <<< $(<data:blog.title/>)</title> <b:else/><b:if cond='data:blog.pageType == "static_page"'> <title><data:blog.pageName/> <<< $(<data:blog.title/> --page)</title> <b:else/><b:if cond='data:blog.pageType == "archive"'> <title><data:blog.title/> --in '<data:blog.pageName/>'</title> <b:else/><b:if cond='data:blog.pageName != ""'> <title><data:blog.title/> --query '<data:blog.pageName/>'</title> <b:else/> <title><data:blog.pageTitle/></title> </b:if></b:if></b:if></b:if>
It have four if clause to do something like switch in C code, it reads more like Python way. The first part item is for posts, static_page for pages, archive for archive pages. The last part—page type is index, it checks if page name is not an empty string, then the current page could be a search result page or label page; homepage or some others not covered if page name is an empty string.
I would like to have some like blog.archivePageYear and blog.archivePageMonth, or to be able to distinguish searching and label pages. So, I could make title read like YJL --verbose --search 'keyword' or --label 'label' or --year 2010 --month September.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.