Lemonstand back to search or category results

December 06, 2012

Today I had to add a basic back to search results implementation and thought i'd blog it for future reference.

I could not find anything implemented in the documentation so decided to add this snippet of code to any of the category or search pages that I had. Be sure to add it inside of the partial which gets re-loaded during pagination changes to continuously update the session as the user browses.

set('back_r', $_SERVER['REQUEST_URI']); ?>

You can imagine whats next, open your product page / product partial (depending on your setup) and add the following lines where you would like to display the back to search results link.

$back_r = Phpr::$session->get('back_r');
if($back_r)
{
    echo '« back';
}

Hopefully this might be of use to someone else.


About me

Hello! I'm David Heward, how are you going? I'm a Senior Devops/Build Engineer, specialising in AWS & Cloud Automation. Based in London. Strong 10+ year background in Software development. Have a read of my blog. Have a look at some of my working projects. Contact me at @davehewy or on Linkedin.