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.
-stm said,
Monday, October 30. 2006 at 13:28 (Reply)
mir fiel gerade auf, daß das Suchfeld ausgerechnet bei Dir
Wenn ich in das Suchfeld klicke, dann geht das "Suchen..." nicht weg. Ich habe das ganze gerade testweise woanders umgesetzt, da funktioniert das problemlos.
Carl said,
Tuesday, October 31. 2006 at 14:38 (Reply)
-stm said,
Wednesday, November 1. 2006 at 04:09 (Reply)
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.
Carl said,
Wednesday, November 1. 2006 at 08:41 (Reply)
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.