Creating a Blog Search Page for Lemonstand written by Simon Stevens and updated on 18 October, 2013

Credit: 96dpiThe default Lemonstand page setup doesn't come with blog pages at all (bizarre I know), however they very helpfully provide documentation which is enough for most people.

One of the missing features though, is a search page!  Oh noes!

It's very easily added though, steps below :)

  1. Duplicate your main Blog Archive page.
  2. Rename it to Blog Search, update the url as you like.
  3. Add the following code at the start of the page:
    You searched for "<?= h(Phpr::$request->getField('search')) ?>"
  4. Add the following code in the Post Action Code section of the Action tab:
    if($search = Phpr::$request->getField('search')){
    	$search = '%' . $search . '%';
    		"title LIKE :search OR 
    		description LIKE :search OR 
    		content LIKE :search", 
    		array('search' => $search)
  5. .....
  6. Profit!

Now just create a search form that submits to your Blog Search page using a GET method and search variable "search".

Simon Stevens Google+ More Posts

Simon is the resident web developer and co-owner of 3DPixel Ltd. formed March 2003.

Having joined 3DPixel Ltd. in February 2006, Simon adds considerable expertise in client side and server side scripting.

Be the first to Comment