Monday, March 20th, 2006


Blogsome Search has never quite been right, and now I think I know how to fix it.

At the moment, my Search code looks like:

<form id="searchform" method="post" action="/">
    <input type="text" name="s" id="s" size="12" />
    <input type="submit" class="button" name="submit" value="Search" />
</form>

This works, to a certain extent. It will only properly display the first page of results. It is possible to use URLs of the form:

http://schinckel.net/category/?s=searchterm

which will give results, and if there are more hits than are visible, will display the Next Page link, which is of the form: http://schinckel.net/category/?s=searchterm/page/2/, and works.

Knowing this, it’s possible to hack up a JavaScript function that will display the search results, but the Next Page link still fails. You can, however, pop an &paged=n on the end of the URL, which will work in this case.

I think this would be much nicer with a RewriteRule. I’ll have to play around a bit and see what makes a working one for .../search/term1/term2/, I think.

The JavaScript I am using at the moment is (shown in context):

<form id="searchform" method="post" action="/" onsubmit="location.href='/category&s='+document.getElementById('s').value.replace(/ /g,'+');return false;">
    <input type="text" name="s" id="s" size="12" />
    <input type="submit" class="button" name="submit" value="Search" />
</form>
View Comments (3)   RSS Feed for Comments on this Post

A Blogsome user wanted to use the URL switch ?order=asc to get an ascending list of posts by date. I suggested it would’t work, but they tried it in the form:

http://schinckel.net/category&order=asc

And it worked!

It only seems to work for category pages, although I think the above URL will actually catch every post, as each post lives in at least one place within the /category hierarchy.

This opens up huge opportunities to use other URL switches to get other effects under Blogsome.

I’m off to the Wordpress Codex, to see what else I can use!

I Wasted TimePaul Kelly…Nothing But A Dream ★★★★

View Comment (1)   RSS Feed for Comments on this Post