brandnewbox.co.uk

Home of Andrew Weaver, a uk-based web developer specialised in building high-quality websites

A simple ExpressionEngine search page

Thursday, January 25th, 2007

Andrew Weaver

Category:

Expression Engine provides a handy search module that provides an easy mechanism for adding a search facility to your site.

This first article implements a simple search box and results page.

Create the search box

This is a simple variation of the Simple Search Form from the EE documentation. This could be put into its own template or more likely be part of a global header embedded into every page.

{assign_variable:my_weblog="default_site"}
{assign_variable:my_template_group="site"}

{!-- your page header --}

{exp:search:simple_form weblog="{my_weblog}"}

 
{/exp:search:simple_form} {!-- your page footer --}

An optional result_page="search/results” can be added to the exp:search:simple_form tag to specify the search results page.

An example search box can be seen here.

The search results page

This will be in its own template (eg, search/results) wrapped in the site’s header and footer.

For usability we could include the search box again (with the search term filled in):

{!-- your page header --}

{exp:search:simple_form weblog="{my_weblog}"}

 
{/exp:search:simple_form}

Before displaying the results:


<p>Searching for: <b>{exp:search:keywords}</b> found {exp:search:total_results} results.</p>

{exp:search:search_results}

{title}
{excerpt}
{/exp:search:search_results} {!-- your page header --}

This will display the search results in a simple, definition list.

Comments

1. Sue Crocker
13th Jun 2007 at 7:57 am

I tried looking for expressionengine, since that’s the offical name of the product. :) No matches.

But I did find them when searching for expression engine.

2.
12th Dec 2007 at 7:42 pm

what happens if you have more than one weblog on your site and you want to search them all?

3. Yassir
16th Jan 2008 at 6:59 am

@steve
Easy. Just add this parameter search_in="everywhere" to the {exp:search:simple_form} tag :)

4. User-Luser
1st Feb 2008 at 10:48 am

I invite you to attend our new blog. Its maintenance for certain will interest you visitors.
We wait for you on the most fair blog:

http://blogaboutme12711.blogspot.com

http://blogaboutme98641.blogspot.com

http://blogaboutme38409.blogspot.com

Add a comment

 
Remember my personal information
 
Notify me of follow-up comments?
 

© brandnewbox.co.uk 2004-2008