00507: jump from the search field to a page instead of searching

Summary: jump from the search field to a page instead of searching
Created: 2005-09-03 01:25
Status: Closed - available in Cookbook
Category: Feature
From: Schlaefer
Assigned:
Priority: 2
Version: 2.0+
OS:

Description: Often you know the name of the page you want to visit. Instead of typing it into the url it would be more elegant to have a jump feature for the search field. With a "jump" button for regular users and a "shortcut" for more experienced users.

Shortcut: for example we use a dot as first character in the search field to indicate that we want to perform a jump instead of a search.

If the page does not exists a normal search should be performed.


See SearchExtensions


Thanks, I didn't found this before. Profiles September 03, 2005, at 10:05 AM

FYI: Because I only wanted the fast jump from the searchfield I'm using this now:


SDV($JumpNSearchTrigger, ".");
define('jumpnsearch', 1);

if ($action == 'search') {
	$text = stripmagic($HTTP_GET_VARS['q']);
	$jumpto = '';
	if (strpos($text, $JumpNSearchTrigger) == 0) { 
		$text = substr($text, 1);
		$text = preg_replace("/\\s*/", "", ucwords($text));
		if (preg_match("/^$GroupPattern([\\/.])$NamePattern$/", $text)) 
			$jumpto = $text;
		elseif (strrpos($text, "/") == strlen($text)-1 ) {
			$text = substr($text, 0, strlen($text) - 1);
			$jumpto = FmtPageName("$text.$DefaultName", $pagename);
			if (!PageExists($jumpto))
				$jumpto = FmtPageName("$text.$text", $pagename);
		}
		elseif (preg_match("/^$NamePattern$/", $text))
			$jumpto = (isset ($HTTP_GET_VARS['group'])) 
				? stripmagic($HTTP_GET_VARS['group']).".$text" 
				: FmtPageName("\$Group.$text", $pagename);
		if ($jumpto && PageExists($jumpto))
			Redirect($jumpto);
	}
}