Wednesday, September 22, 2010

Hacking labels and categories into feeds

In a previous installment we looked at how to help readers find only the articles written by one particular author in a Blogger multi-author blog. Here we look at more hacks employing labels and feeds.

feed-hackGoogle labels, even though one-dimensional, are a very powerful feature that can help you make the best of either Gmail or Blogger. Google Mail hacks are discussed elsewhere, here we’ll focus only on Blogger.

Most major blogging platforms include ways of obtaining feeds for specific categories. This is a little known feature, as most publishers are not interested in segmenting their content in such a manner, particularly since subscriptions to specific categories only could be difficult to track and may cause an increased burden on their server.

With Wordpress, you can use

<?php get_category_feed_link( $cat_id, $feed ); ?>

where $feed can be either ‘rss2’ or ‘atom’ and is optional. In practice, this results in the following URL: http://domainname.com/blogfolder/?feed=rss2&cat=n, or, if custom permalinks are used, http://domainname.com/category/maincategory/subcategory/feed. Such a feed will come up with the name of the blog, but most blog readers will allow you to customize it easily.

With Blogger, we have category feeds as http://<subdomain>.blogspot.com/feeds/posts/default/-/<label1>/. If there’s a custom domain, we obviously have http://www.customdomainblogger.com/feeds/posts/default/-/<label1>/. Let’s summarize the special feed format for both platforms:

FEED Blogger Wordpress
Site http://<subdomain>.blogspot.com/feeds/posts/default http://example.com/feed/[rss|rss2|rdf|atom] or
http://example.com/?feed=[rss|rss2|rdf|atom] if permalinks
Comments http://<subdomain>.blogspot.com/feeds/comments/default http://example.com/comments/feed/ (permalinks)
http://example.com/?feed=commentsrss2 (default)
Article C. http://<subdomain>.blogspot.com/feeds/<PostID>/comments/default http://example.com/post-name/feed/
Category http://<subdomain>.blogspot.com/feeds/posts/default/-/<label1>/ http://domainname.com/blogfolder/?feed=rss2&cat=n
(http://domainname.com/category/maincategory/subcategory/feed if custom permalinks)
Authors ? http://example.com/author/authorname/feed/

For all Blogger feeds the default is Atom 1.0; to obtain RSS 2.0 feeds, simply replace “default” with default?alt=rss. You can find the postId of an individual post from the Posting | Edit Posts tab. Simply mouseover the 'Edit' link next to a particular post, and that postId will be displayed in your browser's status bar.

Wordpress offers more flexibility in terms of building logical constructs into the feed:

  • http://www.example.com/?cat=42&amp;feed=rss2
  • http://www.example.com/?tag=tagname&amp;feed=rss2
  • http://example.com/category/categoryname/feed
  • http://example.com/tag/tagname/feed
  • http://example.com/?s=searchterm&feed=rss2 (search)
  • http://example.com/?cat=-nsfw&feed=rss2 (exclusion)

Blogger allows only concatenating labels (categories):

http://<subdomain>.blogspot.com/feeds/posts/default/-/<label1>/<label2>/.../<labeln>

Negations (exclude a label) and disjunctions (or) are not supported yet:

http://<subdomain>.blogspot.com/feeds/posts/default/-/dance/-fashion
http://<subdomain>.blogspot.com/feeds/posts/default/-/dance%7Cfashion

Most of these hacks are only indirectly useful to the publisher, as less control can be exercised over such runaway feeds. What a Blogger publisher could do, however, is provide the feedburned version of the following:

Published
                        <b:if cond='data:post.dateHeader'>
                        on <data:post.dateHeader/>
                        </b:if>
                        <data:post.timestamp/>
                        <b:if cond='data:post.labels'>
                       . You can find similar articles under the following categories:
                        <b:loop values='data:post.labels' var='label'>
                        <a expr:href='data:label.url' rel='tag'><data:label.name/></a> (<a expr:href='data:blog.homepageUrl + &quot;feeds/posts/default/-/&quot; + data:label.name' expr:title='&quot;RSS feed for &quot; + data:label.name'><img alt='Subscribe' src='http://www.feedburner.com/fb/images/pub/feed-icon16x16.png' style='vertical-align:middle;border:0'/></a>)<b:if cond='data:label.isLast != &quot;true&quot;'>,</b:if>
                        </b:loop>
                        </b:if>
                        .

The above is a rather clever hack, but most readers would not quite understand what it means. Here’s what it looks like on a foreign-language blog using the Aspire template:

Blogger Category Feed Hack

To control the feeds and obtain stats, one would have to burn each category feed with feedburner in a format such as http://feeds.feedburner.com/<MainBlogFeedName>/<label>. It is then possible to change the format of the feed in the “label loop” so that the actual feed is provided by feedburner.

Whichever hacks you choose to use, though they may seem more useful to a reader, the publisher will derive a benefit from improved customer satisfaction.

LE: Interesting discussion on CamenDesign on what RSS is and what it could be.

Sources / More info: Google Data Protocol Reference, Blogger Support Feeds, wp-codex-feed-link, wp-feeds, yt-feeds

No comments:

Post a Comment

Thank you for commenting and rest assured that any and all comments are welcome, whether positive or negative, constructive or distructive. Unfortunately, if you comment in this view I might not know about - please use the regular (Desktop) view.
I am using Disqus for commenting, but Blogger is not showing it so your comments may end up not being displayed - tell Google about it!