Customizing Blogger's Search Result Pages With searchQuery

In January of last year I wrote an open letter to Blogger asking them to expand the pageType attribute. It was an appeal to add to the existing functionality in Blogger and fix what I perceived to be bugs and oversights. I included proposals for new pageType values, why we needed them and the problems they would solve. Blogger never responded. The good news: I've figured out a solution for almost every original problem!

The problem with Blogger is that a lot of the cool stuff is undocumented. It's only when you examine the raw code like I have that you can really see Blogger's potential. Why is this stuff is undocumented? Blogger needs to get the Google Code people to redo their documentation. Maybe it's me, am I asking for too much? I don't even enjoy writing these types articles (so tedious) but I do it because I want the information to get out there.

So yeah, I'm making this a week long event because writing one giant post would take me forever. People with ADD know what I'm talking about. Today's solution is to the search pageType value proposal. Tomorrow, something else...

Re: search pageType Value Proposal


Problem: I'd like to know when my visitors are browsing Blogger search results and I'd also like to know the search terms they used.

Solution: All of this can be done with the searchQuery global layout data tag. As the name implies, globally available layout data tags can be used anywhere.

Possibilities: I haven't played much with this except to indicate in the page title when you're browsing search results. I might include the complete tag list on the search page and maybe some other stuff. It's even possible to change the layout of the page and how posts are displayed. Maybe on search pages you might want to cut out the body portion of blog posts and keep just the headlines. Maybe hide some widgets while you're at it. Have a LinkList widget only appear on search pages. Even if you don't take advantage of customized search pages it's nice to know you have the option.

Notes: I've only tested searchQuery with the standard Blogger search. I don't know if this will work with the Search Box Gadget. To be honest I forget all about it. Also, I've decided not to use it so until I finish all my other projects I won't have the free time to examine the Search Box Gadget.

5 Comments

The One - #
February 25, 2010 at 3:20 PM
Thanks it works and now I can probably add some content to fill the search query page, especially when it is no result
Anonymous - #
March 19, 2010 at 5:18 AM
BROWN MONKEYS CAN'T FUCKING DRIVE!!!
Alain-Christian - #
March 19, 2010 at 2:16 PM
Can't argue with that!
Anastasia - #
April 18, 2010 at 11:17 PM
This post has been really helpful for me.

You haven't posted (that I can see) how you dealt with the issue of labels, so I thought I would share what I came up with. Basically, I use the conditional statements to include all index pages, exclude all pages with an empty page name (both the homepage and the older posts you can navigate to from the homepage have empty page names), and exclude all search results (using the searchQuery tag you mention here).

What you should be left with are only the label search results pages, and since the page names for those are the label names, you can use that data to print the label name that was accessed anywhere you want on the page.

Thanks for this.
Alain-Christian - #
May 23, 2011 at 2:13 AM
@Anastasia
Sorry to keep you waiting, I've finally posted a guide to the Seven Blogger Page Types. Your solution is really close by the way. On the code snippet I posted only one data tag is different if I'm reading you correctly.

Sorry to keep everyone waiting so long. ^_^;;

Add a Comment