Code Snippets: Categorizing Blogger entries
Update 02/08/06: This posting explains how to create categories using the posting's title. If you don't like inserting the category name in the title you can read my other posting (Blogger Categories in 5 minutes)
---------
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:
http://search.blogger.com/?Submit=Search+Blogs&as_lq=
ui=blg&hl=enas_q=&as_epq=as_oq=&as_eq=
bl_pt=%22Virtual+NYC+Tour%22&bl_auth=as_drrb=q
&as_qdr=as_mind=1&as_minm=3&as_miny=2005
&as_maxd=16&as_maxm=1&as_maxy=2006bl_bt=
&bl_url=websitesandmore.blogspot.comlang=all
&safe=active
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:
http://search.blogger.com/?ui=blg&bl_pt=Virtual+NYC+Tour
&bl_url=websitesandmore.blogspot.com&as_q=
I then created a javascript function that will be responsible for showing the category. Insert the following code in any part of your blog template after the <html> tag:
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
<a href="javascript:showCategory('THE CATEGORY');">THE CATEGORY</a>
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_
---------
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:
http://search.blogger.com/?Submit=Search+Blogs&as_lq=
ui=blg&hl=enas_q=&as_epq=as_oq=&as_eq=
bl_pt=%22Virtual+NYC+Tour%22&bl_auth=as_drrb=q
&as_qdr=as_mind=1&as_minm=3&as_miny=2005
&as_maxd=16&as_maxm=1&as_maxy=2006bl_bt=
&bl_url=websitesandmore.blogspot.comlang=all
&safe=active
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:
http://search.blogger.com/?ui=blg&bl_pt=Virtual+NYC+Tour
&bl_url=websitesandmore.blogspot.com&as_q=
I then created a javascript function that will be responsible for showing the category. Insert the following code in any part of your blog template after the <html> tag:
<script language="javascript">
var blogUrl = "YOUR BLOG ADDRESS";
function showCategory(category){
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;
}
</script>
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
<a href="javascript:showCategory('THE CATEGORY');">THE CATEGORY</a>
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_

33 Comments:
This only solve the category browsing issue, but is there any way I can decide with category a post belongs to when posting?
By
Machilus, at 1/17/2006 10:05 PM
Yes, you can categorize your new postings. Maybe my blog entry was not clear enaugh. When you create a new posting add the name of the category to the postings title.
Example. you have a new posting that you want to add to "Category A". The title would look something like
Title:
Category A: POSTINGS TITLE
By
Taher Baderkhan, at 1/17/2006 10:13 PM
Hi Taher,
I'm curious why you don't like the delicious approach. I'm sure you're aware of the benefits (like multiple categories for the same post, keeping readers on your pages, evolving categories over time etc, fancy pants integration with other web apps and the rest).
Is it too hard to add the tags to each post?
I'm not attacking your work here - this is as good an implementation of the "search the blog for tags" approach as I've seen. But I would like to know what's blocking your take-up of the delicious approach, so that I can work to overcome it.
By
Greg, at 1/18/2006 10:19 AM
Hi Greg,
I should have explained more about why I did not like the delicious tags. I will also update my blog to include the reason. As you said, there are a number of advantages to the delicious tags and I agree with you on those issues. The problems that I had with delicious are available in this new posting
By
Taher Baderkhan, at 1/18/2006 11:14 AM
Hi Taher,
I've created a "new" method for categorization using BlogSearch. Please do take a look at it in my blog:
http://paulosebastiao.blogspot.com/
It basically uses CSS to allow the categories to be hidden in the post title. When you have multiple categories it's pretty annoying having something like:
- categoryX, categoryY, categoryZ: This is my post
Let me know what you think of it.
Thanks,
Paulo
By
doraemon, at 1/21/2006 3:56 PM
Me again. Forgot to say that most of the work was done by you. ;)
By
doraemon, at 1/21/2006 3:57 PM
wonderful. thank you.
By
B-Rock, at 1/25/2006 11:03 PM
I really like this method above all others! In fact, we were already using Title heading (i.e. Videos: XXX), so this is perfect!!!!
By
Anonymous, at 1/27/2006 3:56 PM
Check out what I did at my blog related to categories: http://nerdierthanthou.nfshost.com/
By
Amit, at 2/02/2006 8:19 AM
One problem with the code here is that the category (search results) are shown in order of relevance, and nor in order of data. This is a problem since in a blog you would want your entries to be in chronological order.
A small modification in the code would make the Category "results sort by date". I have posted the modified code at http://imdeng.blogspot.com/2006/02/how-to-create-categories-in-blogger.html
By
Sanjeev, at 2/10/2006 11:23 AM
Does anyone know why I am getting a search that looks like this:
blogurl:fullofthings.blogspot.com inposttitle:""Jon Book":"
When that happens, I get results that contain "Jon" in the title and "book" in the post itself.
Any ideas?
By
s, at 2/22/2006 11:58 PM
Hi Taher,
This is simply a repost of the comment I made over on your "Why I don't like the delicious method" post. I wanted to make sure you got it.
Here's why I don't like the delicious approach as a novice blogger. First, as Taher states, using delicious takes you away from the main blogger page. Second, you have to do some editing to each post you make such that it works....yuck. So far, Taher's method is one step better. However, both fail on this account (Taher's method still goes away from your specific blog to the general Blogger search site). I'd love to have categories keep the reader right in my blog. Unfortunatley, Taher (and I realize this may be the only way to do it) I don't like having to prefix my entries with the category name either. I would be great if you could simply write your post, click what category you want it in and your done. I'd love the category function to be seamless. The delicious method just seems way to tricky, basically having to manually tag every post using manual coding. For someone like me who wants only two or three catergories forming what I envision as a real "multiblog", it needs to be much easier. I feel I jumped the gun by going with blogger, if wordpress does this automatically. And, as so many have pointed out, this really is the only way to go if you want to blog a lot. Some of the best formats are www.tompeters.com or www.radicalcareering.com/hogblog/index.php. I'd love for categories to be like that.
By
Gabe, at 2/25/2006 12:59 AM
guys, this is a bit late may be, but this hack would only work if google had indexed your site, right? i'm relatively new and i'm not sure that my blog is properly indexed by google (i tried search on the older posts and it didn't return any results). is there anyway to go around this?
By
treespotter, at 3/10/2006 3:10 PM
I am a novice blogger - and it worked beautifully. Thanks!
By
Anonymous, at 4/08/2006 1:31 AM
Genius. Thank you!
Has an interesting impact on my tracking, as well. Essentially, people are now 'leaving' the blog and then 'returning' when they search through categories.
As a personal blog, it doesn't matter much, but if I were doing something proper with the footfall (e.g. advertising...), it would be a little deceiving as to # of visitors!
Thanks again!
By
krill54, at 4/22/2006 8:21 AM
Nice idea, however, i do not like, that the category name is in the permalink.
Steffen
informatik-praxis.blogspot.com
By
Steffen Mazanek, at 5/12/2006 11:04 AM
I tried this on my testbed before implementing it on another site, and while I have the javascript and the categories established, it doesn't seem to find the posts. It switches to the blogger search page, but doesn't find anything. Can you help?
By
Joshua Ballard, at 6/15/2006 9:49 PM
I think I may have found my solution...it was a simple url typo...embarrassing is not the word.
Thank you for your help
By
Joshua Ballard, at 6/15/2006 10:00 PM
Hi!
I like your story.
But you'd better take a look here to find a really DIFFERENT dating site.
Looks amazing, agree? :-)
You can also find my pics and more about me on my page www.livedatesearch.com/jessica
Read more about me or drop me a message from there.
Chao!
Jessica
By
Anonymous, at 2/09/2007 6:29 AM
Gutten TAG!
Nice work!
We enjoyed visiting your website very much. Here a lot of helpful information.
Another links here:
[url=http://onlinecasinos-online.blogspot.com/]online casinos[/url] http://onlinecasinos-online.blogspot.com/ online casinos
[url=http://onlinecasinos-here.blogspot.com/]onlinecasinos[/url] http://onlinecasinos-here.blogspot.com/ onlinecasinos
[url=http://craps-onl.blogspot.com/]craps[/url] http://craps-onl.blogspot.com/ craps
[url=http://gambling-online-s.blogspot.com/]gambling online[/url] http://gambling-online-s.blogspot.com/ gambling online
[url=http://ws-poker.blogspot.com/]world series of poker[/url] http://ws-poker.blogspot.com/ world series of poker
Ciao!
By
Anonymous, at 2/18/2007 6:53 AM
What a great site running trails in arizona 2000 isuzu cd changer err3 Springpedic mattress factory Free business cards for kids Olympic running record canvas house awnings http://www.withdrawal-from-percocet.info Phentermine 76 free consult free shipping Como fabricar plotters para vidrio What does the medicine valtrex do To+wax+a+car Sydney webcam fishing math games Tits hardcore lingerie
By
Anonymous, at 3/04/2007 8:22 PM
Hi
Nice work!
Now I understand, that for site creation it is necessary to be not webmaster, but the psychologist. Tomorrow I shall return again.
Also visit my sites:
[url=http://xenical.butkel1.org/]xenical[/url] http://xenical.butkel1.org/ xenical
[url=http://hydrocodone.butkel1.org/]hydrocodone[/url] http://hydrocodone.butkel1.org/ hydrocodone
[url=http://celexa.butkel1.org/]celexa[/url] http://celexa.butkel1.org/ celexa
[url=http://ephedra.butkel1.org/]ephedra[/url] http://ephedra.butkel1.org/ ephedra
[url=http://lorcet.butkel1.org/]lorcet[/url] http://lorcet.butkel1.org/ lorcet
[url=http://meridia.butkel1.org/]meridia[/url] http://meridia.butkel1.org/ meridia
[url=http://tramadol.butkel1.org/]tramadol[/url] http://tramadol.butkel1.org/ tramadol
[url=http://carisoprodol.butkel1.org/]carisoprodol[/url] http://carisoprodol.butkel1.org/ carisoprodol
[url=http://cialis.butkel1.org/]cialis[/url] http://cialis.butkel1.org/ cialis
[url=http://paxil.butkel1.org/]paxil[/url] http://paxil.butkel1.org/ paxil
[url=http://clonazepam.butkel1.org]clonazepam [/url] http://clonazepam.butkel1.org clonazepam
[url=http://lortab.butkel1.org]lortab[/url] http://lortab.butkel1.org lortab
[url=http://lexapro.butkel1.org]lexapro[/url] http://lexapro.butkel1.org lexapro
[url=http://codeine.butkel1.org]codeine[/url] http://codeine.butkel1.org codeine
[url=http://viagra.butkel1.org]viagra[/url] http://viagra.butkel1.org viagra
[url=http://vicodin.butkel1.org]vicodin[/url] http://vicodin.butkel1.org vicodin
[url=http://percocet.butkel1.org]percocet[/url] http://percocet.butkel1.org percocet
[url=http://ativan.butkel1.org]ativan[/url] http://ativan.butkel1.org ativan
[url=http://oxycontin.butkel1.org]oxycontin[/url] http://oxycontin.butkel1.org oxycontin
[url=http://rivotril.butkel1.org]rivotril[/url] http://rivotril.butkel1.org rivotril
Sayonara!
By
Anonymous, at 3/05/2007 11:34 AM
;-)
Hi Blog mate!!
I hope you don't mind me blogging anonymously like this. I thought the blog was really cool. I am also into betting gambling odds online sports.
I found another interesting website blog at http://gamblingwebsites.blogspot.com. I am constantly looking for ways of making extra money online and think that online gambling could be a way of doing that.
Cheers for now and keep up the good work!
Try linkreferral.com - free website traffic generating and promotion program
By
Anonymous, at 3/08/2007 11:16 PM
headache in child
Joints hurt
Headache
heat of a body
Toothache
Nervous failure of a tablet
Home
joint hurt
migraine headache
sinus headache
tension headache
cluster headache
cause of headache
headache rack
migraine headache symptom
chronic headache
1 2 3 charge headache heal pain program taking
tension headache symptom
headache treatment
headache relief
frequent headache
child headache
sinus headache symptom
migrain headache
complete fully guide headache headache help medication relieve revised that them understanding updated
headache nausea
constant headache
truck headache rack
stress headache
headache in child
type of headache
high blood pressure headache
severe headache
pregnancy headache
auto brainer fewer headache higher landlording no pilot profits simple system
headache in the pelvis
heal your headache
chronic daily headache
cause of migraine headache
headache cure
common common edition fix headache hurry in not problem second so window xp
headache and dizziness
migraine headache treatment
complete fully guide headache medication relieve revised them understanding updated
sex headache
orgasm headache
barometric pressure headache
botox for headache
allergy headache
cure enlightening epic head headache in only quest slightly totally unreasonable unrelenting
pressure headache
headache during pregnancy
occipital headache
chronic tension headache
icepick headache
thunderclap headache
cause of constant headache
flu have headache horrible i
cluster complete guide headache headache magnesium magnesium migraine migraine naturally prevent solution treat using
headache symptom
sinus headache relief
headache neck pain
migraine headache medication
headache clinic
menstrual headache
hormone headache
200 eat food headache migraine recipe relief
headache pain
aluminum headache rack
persistent headache
headache medicine
migraine headache relief
chronic headache cause
book cook eating headache headache migraine other prevent prevention right
headache pressure point
headache diary
chronic headache in new pain pelvic pelvis prostatitis treatment understanding
headache and blurred vision
ad advertising arnold commercial headache japanese pill schwarzenegger weird
cluster headache symptom
excedrin tension headache
international headache society
migrane headache
can eat have headache i if live migraine nutrition
no headache visor
post dural puncture headache
acupuncture and headache
spinal headache
alternative definitive guide headache medicine
headache medication
bad headache
blood pressure headache
fatigue and headache
tension type headache
sinus headache treatment
migraine headache medicine
semi headache rack
cluster headache imitrex
headache pain relief
coital headache
common common fix headache hurry in mac not os problem so x
conquering headache
natural headache relief
asthma cause epilepsy glutamate headache heart illness major monosodium preventable such treatable
headache after sex
away chronic curing headache migraine neck neck pain pain prolo prolotherapy
body heat
body heat movie
kathleen turner body heat
body heat tanning
body heat 2
excessive body heat
body builder in heat clip
body in heat
body builder in heat
body builder in heat free
quincy jones body heat
girl body heat
body exchanging heat in passenger seat
boy die from toothache
home remedy for toothache
boy die toothache
death toothache
oil of clove toothache
how to stop a toothache
britney spear toothache
child die from toothache
boy die maryland toothache
toothache remedy
boy die from maryland toothache
12 die from old toothache year
child die toothache
britney toothache
how to get rid of a toothache home remedy
die from kid toothache
ambesol for toothache
boy kill toothache
natural toothache remedy
deadly toothache
death kid lead toothache
alberts toothache
boy fatal proves toothache
natural cure toothache
alligator toothache
cavity home remedy toothache
death from toothache
toothache after a root canal
ambisol drug toothache
toothache relief
boy died from toothache
die toothache
12 die old toothache year
after boy die toothache
12 boy die old toothache year
gum home remedy toothache
toothache xanax
12 boy die from old toothache year
clove for toothache
best medicine for toothache
toothache treatment
toothache tree
after boy die maryland toothache
boy die from md toothache
home cure for toothache
By
Anonymous, at 5/01/2007 9:47 AM
Valium
Verapamil
Viagra
Cipralex
Citalopram
Celebrex
Codiovan
Cefixim
Cephalexin
Doxepin
Diazepam
Dolviran
FEVARIN
Fluoxetin
Formigran
Zoloft
Zyban
Zaldiar
Zocor
Trevilor
Tramadol
Tavegil
Arcoxia
AVANDIA
ACOMPLIA
Biaxin
Ezetrol
Isotret
Ibuprofen
Klipal
Levitra
Lisihexal
Menogon
Mirtazapin
Omeprazol
Allergy
Blood Pressure
Muscle Relaxant
Contraceptive
Arthritis Rheumatics
Birth Control
By
Anonymous, at 5/18/2007 10:22 AM
I totally agree with views expressed above. In fact I strongly believe with what is being said in this blog.
If anyone would like to comment or chat let me know.
Free Dating Advice by Tanya...
tanya@allaboutsingles.com
username: maryjanelove
System-Admin of the hottest singles site on the Internet
Mention this blog and I will give you one month free>>> have a happy day
http://www.allaboutsingles.com
Singles chat
http://singlessites.blogspot.com/
By
Pain Killer Mary, at 8/05/2007 12:12 PM
Relpax pharmacy
drugs Maxalt pharmacy
Zomig pharmacy
drugs Omeprazol pharmacy
Xatral pharmacy
Citalopram xanax ratiopharm
Risperdal xanax tafil
Telfast pharmacy
drugs Sirdalud
Regenon
drugs Zaldiarpharmacy
Glucobay pharmacy
By
Anonymous, at 9/04/2007 5:52 AM
Young Fatties
By
Michael, at 9/28/2007 7:35 AM
buy cheap viagra online
By
Kael, at 10/04/2007 7:54 AM
With the trades and acquisitions made going into the draft, plus the bulk of the team that is carried over from last season, and the trades and draft picks made during the draft, it sure seems like the Pats are going to be the team to beat in the AFC this season, and perhaps in all of the NFL.
Considering the Pats were almost in the Superbowl last season with a pathetic receiving corps and that they've added very talented players into said receiving corps this season, barring some nasty injury(ies), they look to be the team to take it all.I say injury(ies) because I think they could survive an injury or two to some positions, but if they lost Brady they'd probably have a hard time recovering.
I wish I could say that the Redskins did well in the draft and/or in free agency but so many holes still exist that I'm not sure they'll be significantly better than last season. I suppose on face they should be if they can keep their corners healthy. With Landry (argh, hard to type that name as a Redskin!!) back there with a healthy secondary they might be able to cheat up more and put more pressure on opposing QBs. Might.
They still have what should be a lot of talent in the receiving positions, and Campbell should be better, but they don't have the quality on either line (offense or defense) that I wish they'd have, so it could be yet another year of .500 at best, or worse.
Still, the NFC East looks to be the NFC Least again this season. None of the teams there look like they'll be that good, and none really look ready to step up and take the division.
Great super bowl xlll odds, Sports Betting Information, NFL Odds, Football Betting,
sportsbet, sports betting lines, vegas sports betting. Visit us for more info at: http://www.bet911.com
By
Anonymous, at 10/11/2007 12:52 PM
I am new to blogging and have got around most of the basic steps. Categorization was on my mind and did not how to fix it.
Your post talks about adding the javascript code before the HTML tag. Where exactly do I find that?
Do I add the javascript/html page element and paste the code ? or is there an another place ?
Can you please help me here.
Thanks
Bud!
By
airbuddy, at 6/10/2008 1:50 AM
Your template could not be parsed as it is not well-formed. Please make sure that all XML elements are closed properly.
XML error message: The markup in the document following the root element must be well-formed.
Hmmmm - this is the message I get when I try this fix. And nto being an html programmer I have no idea what it means. Can you help?
Thanks!
Sam
By
Sam, at 10/10/2008 8:41 AM
The three ED medications currently available in the market i.e. the Viagra, Levitra, and Cialis are all the same in terms of working and side effects. The most common side effects are headaches and facial flushing, which occur in 15% of men. http://www.viagrathunder.com
By
Dr. Davida, at 2/06/2009 12:45 AM
Post a Comment
Links to this post:
Create a Link
<< Home