linking back to search results

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
blackhawk
Power Poster
Power Poster
Posts: 280
Joined: Mon Oct 20, 2008 6:07 pm

linking back to search results

Post by blackhawk »

with the search module, is there a way to create a link back to the search results page? instead of clicking on the back button of the browser window?

thanks
Zoorlat

Re: linking back to search results

Post by Zoorlat »

You can always add your own back-button in your template

Code: Select all

<a href="javascript:history.go(-1)"> [Go Back]</a>
But then the link will show on the page regardless of whether a visitor came by searching or not.

In any case, don't underestimate your visitors, most surfers know how to use the back-button. It is always a good GUI design strategy to allow users to use what they are used to  :D
viebig

Re: linking back to search results

Post by viebig »

There is a elegant way to solve it

It´s possible to show the "back to results" link only when the user came from a search results page.

If you´re interested, let me know.

Regards
lainyrache
Forum Members
Forum Members
Posts: 106
Joined: Thu Oct 05, 2006 11:27 am

Re: linking back to search results

Post by lainyrache »

Hi viebig,
I'm not the original poster but....
I would be very interested in your elegant solution for a 'back to search results' link.
Can you possibly let me know?
Many thanks,
Rachael
viebig

Re: linking back to search results

Post by viebig »

Sure Rachel... let´s use one UDT

Name it backsolution

Code: Select all

$url = parse_url($_SERVER['HTTP_REFERER']);

$currenturl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

if($url['host'] == $params['site'] && $_SERVER['HTTP_REFERER'] != $currenturl)
{
return '<a href="'.$_SERVER['HTTP_REFERER'].'" title="Back Link">'.$params['text'].'</a> ';
}
Then use it like that on your pages

Code: Select all

{backsolution site='www.yourdomain.com' text="Go Back"}

The back button will only show if the last page accessed by the user was from your domain, and if was a direct hit , nothing will appear.

Let me know your thoughts
lainyrache
Forum Members
Forum Members
Posts: 106
Joined: Thu Oct 05, 2006 11:27 am

Re: linking back to search results

Post by lainyrache »

Thanks for getting back to me so quickly!

Unfortunately, this isn't doing exactly what I was looking for. I have put the tag on my default template page and it shows on every page on my site. I would like it to only show on a search result page, to get back to the search results list page.

Any ideas how I could get it to do this???

Thanks again  ;D
Rachael
viebig

Re: linking back to search results

Post by viebig »

That´s even more simple!

Sorry that I didnt get for the 1st time

update your tag

Code: Select all

if(strpos($_SERVER['HTTP_REFERER'],"mact=Search") !== false)
{
return '<a href="'.$_SERVER['HTTP_REFERER'].'" title="Back Link">'.$params['text'].'</a> ';
}
and now just use param text

Code: Select all

{backsolution text="Return to search results"}
And applaud me if it works!

Regards
Last edited by viebig on Tue Feb 03, 2009 3:59 pm, edited 1 time in total.
lainyrache
Forum Members
Forum Members
Posts: 106
Joined: Thu Oct 05, 2006 11:27 am

Re: linking back to search results

Post by lainyrache »

;D ;D ;D

Spot on - brilliant
Thanks viebig - that's great!
Thanks for taking the time to help with this...
Rachael
Post Reply

Return to “Developers Discussion”