Creating a quicksearch form for Serendipity

Carl discovers the world

  • RSS Feed
  • Login
  • Contact
Ning Themes
Skins 4 Ning, CSS tips, PHP hacks, howto's and theme doc's
Keyword Elite
I use Keyword Elite to find profitable
niches for my online business
Serendipity Directory
Add your site to the Serendipity
Users Directory
Welcome
Herzlich Willkommen


Hi, Welcome to my site, please bookmark me, and feel free to comment on my posts
  • Home
  • About
  • Serendipity
  • Blogger
  • Wordpress
 

Tuesday, April 4. 2006

Creating a quicksearch form for Serendipity

Select language: German, Russian, English
When I look at other blogging engines and CMS's I often marvel at the design of their header, and the sites that impress me the most are those that make full use of their header to either give the visitor useful information or allow them to interact more with the site.

As I learn more about usability of webpages I'm realising that the sidebars are the wrong place for some of the plugins we see in Serendipity themes. I particularly dislike seeing the site search form in the sidebar, and I know this is my own preference that probably isn't shared by everyone, but for those designers who think like me, here's a quick easy way of placing a search form with submit button into your header, and also making sure that the quicksearch form won't display in the sidebar.
Lets start by adding the quicksearch form. My form includes a small amount of javascript that places the term 'quicksearch' into the input box. The variable used {$CONST.QUICKSEARCH} comes from Serendipity's language files so should be translated into every language supported by Serendipity.

<div id="search">
<form id="searchform" action="{$serendipityBaseURL}" method="get">
<input type="hidden" name="serendipity[action]" value="search" />
<input type="text" name="serendipity[searchTerm]" value="{$CONST.QUICKSEARCH}..." onFocus="if(this.value=='{$CONST.QUICKSEARCH}...')value=''" onBlur="if(this.value=='')value='{$CONST.QUICKSEARCH}...';">
<input type="submit" name="quicksearch-button" value="Go!">
</form>
</div>

I've placed a wrapper <div> around our search form because regardless of where on your page you place the form you are very likely to want to give it some unique styling. I've also left the hidden input in place. For some reason the search routine built into Serendipity needs the value="search" on the submit button if the hidden input is removed. Obviously this would have prevented me from changing the button text, so by leaving the hidden input in place I have been able to use 'Go!' which is more recognisable to many web users.

So now that our search form is working, it is also possible to make sure that the quicksearch plugin never appears in our sidebar. This is a very easy step to take, and all we need to do is add a couple lines of code to sidebar.tpl file for our theme. Open sidebar.tpl and immediately after the {foreach...} insert the following;

{if $item.class == "serendipity_quicksearch_plugin"}{else}

Now, immediately before the {/foreach} insert this a closing {/if}, so that your entire sidebar.tpl now looks like this;

{if $is_raw_mode}
<div id="serendipity{$pluginside}SideBar">
{/if}
{foreach from=$plugindata item=item}{if $item.class == "serendipity_quicksearch_plugin"}{else}
<div class="serendipitySideBarItem container_{$item.class}">
{if $item.title != ""}<h3 class="serendipitySideBarTitle {$item.class}">{$item.title}</h3>{/if}
<div class="serendipitySideBarContent">{$item.content}</div>
</div>
{/if}
{/foreach}
{if $is_raw_mode}
</div>
{/if}

There you go, you now have a working search form on your theme, and I'm sure you can see the potential for taking the sidebar code and using it in other ways. Good luck.
If you enjoyed this post, make sure you subscribe to my RSS feed.
Posted by Carl in Theming Serendipity at 19:25   Comments (4)
Defined tags for this entry: s9ytechnorati, serendipitytechnorati, smartytechnorati, Templatestechnorati, Themestechnorati
Related entries by tags:
Pixabella04 for Wordpress
Add This Bookmark and Share Widget Code for Serendipity Templates
Hawaii Template for Serendipity Released


Trackbacks
Trackback specific URI for this entry

No Trackbacks

Comments

  1. -stm said,

    Monday, October 30. 2006 at 13:28 (Reply)

    Hallo,

    mir fiel gerade auf, daß das Suchfeld ausgerechnet bei Dir :-) nicht zu 100% zu funktionieren scheint:

    Wenn ich in das Suchfeld klicke, dann geht das "Suchen..." nicht weg. Ich habe das ganze gerade testweise woanders umgesetzt, da funktioniert das problemlos.
  2. Carl said,

    Tuesday, October 31. 2006 at 14:38 (Reply)

    Hi stm, I'm really sorry about this, my technical German is not good. On this site the quicksearch doesn't work lkike this example anymore because I wanted to make the page more accessible to disabled people. I still have more work to do, but the big problem is that I haven't had any disabled or blind people let me know if the site works for them :-(
  3. -stm said,

    Wednesday, November 1. 2006 at 04:09 (Reply)

    > Hi stm, I'm really sorry about this, my technical German is not good.

    But you understand all of my words? Or should I try to translate my words - even if MY technical english is not so good? :-)

    > because I wanted to make the page more accessible to disabled people.

    Can you tell more about the problems for disabled people with the example code? Because I do want to my page be accessable, too.
  4. Carl said,

    Wednesday, November 1. 2006 at 08:41 (Reply)

    The small amount of javascript used to make the 'quicksearch...' text appear and disappear is apparently in violation of accessibility requirements. You can read more at
    http://www.w3.org/WAI/ER/tools/complete

    I still need to do more, my site still fails some accessibility tests (my stylesheet isn't valid, and I fail one of hte color tests with the grey text) in fact I need to really spend a few days working on the template for this site to freshen it up, but that will probably not happen for a few weeks.

Add Comment

Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

 
 
 
Submitted comments will be subject to moderation before being displayed.
 
 

Categories

  • Blogger
  • Blogger Templates
  • Carl's Journal
  • Christmas
  • Humanity
  • Italian
  • Ning Templates
  • Palm z22
  • Science/Nature
  • Technology
  • Screencasting
  • SEO, Traffic
  • Serendipity Blog
  • Basic html/css
  • Download Themes
  • Theming Serendipity
  • Using Serendipity
  • Small Business
  • Spain
  • Spanish
  • Travel
  • Wordpress
  • Xampp WebServer

All categories




U COMMENT
I FOLLOW






My Feedburner Feed
Subscribe to my Feedburner

© 2005-7 Carl Galloway.Template by Carl, artwork by Pixabella. Valid XHTML, CSS