Code Snippets: Categorizing Blogger entries
I was extremely disappointed when I found out that blogger.com does not have a way to categorize your posts. I started looking on the Blogger Addins section which recommended doing a search on Google. I am not sure why categorization for postings is not part of the blogger package. As a programmer I am almost positive that categorization does not require any special coding logic.
Anyway, I started looking for possible plugins. My initial search lead me to few interesting posts however, I was not satisfied with any of them. To mention a couple:
1) OldCola: His method is to create a blog for each category. The user would then create the posting in the desired category, which would send an email to some email account. The email account would then forward the message to the main blog. The problem with his approach is that you will be creating two entries for each posting. Plus you will have to manage multiple blogs rather than one.
2) There were also other methods that involved using delicious. I did not like this approach
As usual I decided to find my own solution through coding. It was actually very simple. The blogger.com provides a search engine for blogs. All I needed to do is use the search engine and pass it the query that I am interested in. I started by looking at the advanced search options for the search.blogger.com. I found out that you could perform a search for a specific phrase in the posting's title. You can also limit the search to a specific blog. That’s basically all I needed.
I started by using search.blogger.com to search for a specific title in my blog. The search.blogger.com generated the following URL in the address bar:
The URL is very long but has a lot of unnecessary text. I trimmed the URL down to the essentials, which made it look like the following:
var blogUrl = "YOUR BLOG ADDRESS";
var encodedCategory = escape("\"" + category + "\"");
var url = "http://search.blogger.com/?ui=blg&as_q=";
url = url + "&bl_url=" + blogUrl + "&bl_pt=" +
encodedCategory + ":";
window.location.href = url;
Make sure to replace the above words [YOUR BLOG ADDRESS] with your blog's address. Don't include the www part of the address. inclose the blog's address in qutations
Categorizing your posts
Every time you create a new posting make sure to prefix the title of the posting with the name of the category. That’s all. For example, if your posting has the title "Nice Flowers" and you want to add it to the category "Garden" then your posting's title should look like this
Garden: Nice Flowers
Creating the Category URL in the sidebar
To create a category section for your blog. The URL for a category should look something like this
Clicking on the link will display all the postings under that category in the blogger search page.
I did not intend this at the begining but I realized that you can even add your posting to more than one category. All you need to do is prefix all the categories to the posting's title. You can seperate categories with commas or semi cololns. For example: If you want to add the "Nice Flowers" posting to the categories "Garden" and "Environment" then the title should look something like this
Garden, Environment: Nice Flowers
The only problem with this solution is that if you insert a new posting it takes few minutes until the blogger search engine indexes your page. So, in the first few minutes clicking the category link won't display your latest posting. I have tested this and I found out it takes around 5 - 10 minutes for your result to be displayed in the category search page. Not bad
You can test the categories in my blog
Categories: Code Snippets_, Blogger Categories_