Add a 'Return to results' link on full page nodes
This snippet adds an 'Return to XYZ' link on full pages where ever you choose to print it. If the use has come from a News page of News teasers and after reading an article wishes to return to the list of News teasers they can click the 'Return to News' link.
This can remember queries such as $page for views and $filter for filtered views.
This link works even when visiting the page from an external site such as a search engine.
It's a more effective alternative to 'javascript.go(-1);'
Snippet:
Login/Register to Comment this Snippet<?php
//in template.php:
#return to results link
function prevPage($link, $path){
$ref = getenv("HTTP_REFERER");
if (strlen($ref) > 5) if (substr(strrchr($ref, '/'), 1) != 'edit') $path = $ref;
return l($link, $path, array('class' => 'backLink'));
}
//function arguments:
//$link - the text to appear as the link anchor
//$path - if visitor came from an external link or search engine use this value to take them to the first page of the //desired view. (example: if the news view was at 'mysite.com/latestnews' the $path would be 'letestnews')
//in node.tpl:
print prevPage('Back To News', 'letestnews');
?>