$e = &$modx->Event;
switch ($e->name) {
case "OnPageNotFound":
if(!$pg) $modx->sendErrorPage();
else {
//Parse out the requested page.
$docid = str_replace("/", "", $_SERVER['REQUEST_URI']);
//Determine if the friendly URLS are in use.
if ($modx->config['friendly_urls'] == 1 && $docid != '') {
//Get the configured friendly URL suffix.
$docidSuffix = $modx->config['friendly_url_suffix'];
//In order to search for aliases, we need to remove the friendly URL suffix.
if(stristr($docid,$docidSuffix)) {
$docid = str_replace($docidSuffix, "", $docid);
}
}
if ($mid) {
//Prepare the message parameters and send the alert.
$subject = "Page not found";
$msg = "Someone tried to access document id $docid";
$modx->sendAlert("Error",$mid,0,$subject,$msg,0);
}
//Build the URL with the search parameter.
$url=$modx->makeUrl($pg,'','&AS_search='.$docid);
//Redirect to the 404 page.
$modx->sendRedirect($url);
exit;
}
break;
default :
return; // stop here
break;
}
<?php
if ($_GET['AS_search'] != '') {
$search = $_GET['AS_search'];
$response = '<p><strong>The requested page "'.$search.'" could not be found.</strong></p>';
$response .= '<p>We are sorry, but we could not find the page you were looking for. The page may have been moved to a new location.</p>';
$response .= '<p>Below are the results for the closest matches. A site map has also been provided beneath the match results.</p>';
} else {
$response = '<p><strong>The requested page could not be found. A site map has also been provided below.</strong></p>';
}
return $response;
?>
[!404Error!] [!AjaxSearch? &AS_showForm=`0` &ajaxSearch=`0` &AS_showResults=`1`!] <h4>Site Map</h4> [[Wayfinder? &startId=`0` &showDescription=`1`]]
$e = &$modx->Event;
switch ($e->name) {
case "OnPageNotFound":
if(!$pg) $modx->sendErrorPage();
else {
if ($mid) {
// send a message to a local account
$docid = $modx->documentIdentifier;
$subject = "Page not found";
$msg = "Someone tried to access document id $docid";
$modx->sendAlert("Error",$mid,0,$subject,$msg,0);
}
$url=$modx->makeUrl($pg,'','&AS_search='.$docid);
$modx->sendRedirect($url,0,REDIRECT_REFRESH);
exit;
}
break;
default :
return; // stop here
break;
}
[!ajaxSearch? &AS_showForm=`0` &ajaxSearch=`0` &debug=`3` &AS_showResults=`1`!]
[29-Nov-08 10:27:30] AjaxSearch 1.8.1 - Php5.2.6 - MySql 4.1.25-Debian_mt1
[29-Nov-08 10:27:30] AjaxSearch - Configuration file default :
<?php
// For a global parameter initialisation use the following syntax $__param = 'value';
// To overwrite parameter snippet call use $param = 'value';
// StripInput user function.
// Uncomment and complete the core function and choose your own function name
// string functionName(string searchstring)
// functionName : name of stripInput function passed as &stripInput parameter
// searchstring : string php variable name as searchString input value
// advSearch : string advSearch variable as advSearch parameter and return value
// return the filtered searchString value
/*
function myStripInput($searchString, &$advSearch){
$advSearch = 'exactphrase';
return $searchString;
}
*/
// StripOutput user function
// Uncomment and complete the core function and choose your own function name
// string functionName(string results)
// functionName : name of stripOutput function passed as &stripOutput parameter
// results : string php variable name as results
// return the filtered results
/*
function myStripOutput($results){
return $results;
}
*/
// searchWordList user function
// Uncomment and complete the core function and choose your own function name
// string functionName()
// functionName : name of searchWordList function passed as &searchWordList parameter
// return a comma separated list of words
/*function searchWordList($params){
switch($params[0]){
case '61':
$list = "primary,school,education,children,teacher,africa,litteracy,bicycle";
break;
case '62':
$list = "primaire,école,éducation,enfants,professeur,afrique,littérature,bicyclette";
break;
}
return $list;
}
*/
?>
[29-Nov-08 10:27:30] AjaxSearch - User configuration - Before parameter checking : Array
(
[config] => default
[version] => 1.8.1
[debug] => 3
[language] => english
[ajaxSearch] => 0
[advSearch] => oneword
[whereSearch] => content|tv
[subSearch] => 5,1
[withTvs] =>
[order] => publishedon,pagetitle
[rank] => pagetitle:100,extract
[minChars] => 3
[AS_showForm] => 0
[resultsPage] => 0
[grabMax] => 10
[extract] => 1:content,description,introtext,tv_content
[extractLength] => 200
[extractEllips] => ...
[extractSeparator] => <br />
[formatDate] => d/m/y : H:i:s
[highlightResult] => 1
[pageLinkSeparator] => |
[AS_landing] =>
[AS_showResults] => 1
[idType] => parents
[parents] =>
[documents] =>
[depth] => 10
[hideMenu] => 2
[hideLink] => 1
[filter] =>
[tplLayout] => @FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html
[tplResults] => @FILE:assets/snippets/ajaxSearch/templates/results.tpl.html
[tplResult] => @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html
[tplPaging] => @FILE:assets/snippets/ajaxSearch/templates/paging.tpl.html
[stripInput] => defaultStripInput
[stripOutput] => defaultStripOutput
[searchWordList] =>
[breadcrumbs] => 0
[tvPhx] => 0
[clearDefault] => 0
[jsClearDefault] => assets/snippets/ajaxSearch/js/clearDefault.js
)
[29-Nov-08 10:27:30] AjaxSearch - tplResult template @FILE:assets/snippets/ajaxSearch/templates/result.tpl.html : <div class="[+as.resultClass+]">
<a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
[+as.descriptionShow:is=`1`:then=`
<span class="[+as.descriptionClass+]">[+as.description+]</span>
`+]
[+as.extractShow:is=`1`:then=`
<div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
`+]
[+as.breadcrumbsShow:is=`1`:then=`
<span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
`+]
</div>
[29-Nov-08 10:27:30] AjaxSearch - tplResults template@FILE:assets/snippets/ajaxSearch/templates/results.tpl.html : [+as.noResults:is=`1`:then=`
<div class="[+as.noResultClass+]">
[+as.noResultText+]
</div>
`:else=`
<p class="ajaxSearch_resultsInfo">[+as.resultInfoText+]</p>
[+as.paging+]
[+as.listResults+]
[+as.paging+]
`+]
[29-Nov-08 10:27:30] AjaxSearch - tplResult template@FILE:assets/snippets/ajaxSearch/templates/layout.tpl.html : [+as.showForm:is=`1`:then=`
<form [+as.formId+] action="[+as.formAction+]" method="post">
<fieldset>
<input type="hidden" name="advSearch" value="[+as.advSearch+]" />
<label for="ajaxSearch_input">
<input id="ajaxSearch_input" class="cleardefault" type="text" name="search" value="[+as.inputValue+]"[+as.inputOptions+] />
</label>
<label for="ajaxSearch_submit">
<input id="ajaxSearch_submit" type="submit" name="sub" value="[+as.submitText+]" />
</label>
</fieldset>
</form>
`+]
[+as.showIntro:is=`1`:then=`
<p class="ajaxSearch_intro" id="ajaxSearch_intro">[+as.introMessage+]</p>
`+]
[+as.showResults:is=`1`:then=`
[+as.results+]
`+]
$e = &$modx->Event;
switch ($e->name) {
case "OnPageNotFound":
if(!$pg) $modx->sendErrorPage();
else {
if ($mid) {
// send a message to a local account
$docid = curPageName();
$subject = "Page not found";
$msg = "Someone tried to access document id $docid";
$modx->sendAlert("Error",$mid,0,$subject,$msg,0);
}
$url=$modx->makeUrl($pg,'','&AS_search='.$docid);
$modx->sendRedirect($url);
exit;
}
break;
default :
return; // stop here
break;
}
function curPageName() {
$curPage = str_replace("/", "", $_SERVER['REQUEST_URI']);
return $curPage;
}
$e = &$modx->Event;
switch ($e->name) {
case "OnPageNotFound":
if(!$pg) $modx->sendErrorPage();
else {
//Parse out the requested page.
$docid = str_replace("/", "", $_SERVER['REQUEST_URI']);
//Determine if the friendly URLS are in use.
if ($modx->config['friendly_urls'] == 1 && $docid != '') {
//Get the configured friendly URL suffix.
$docidSuffix = $modx->config['friendly_url_suffix'];
//In order to search for aliases, we need to remove the friendly URL suffix.
if(stristr($docid,$docidSuffix)) {
$docid = str_replace($docidSuffix, "", $docid);
}
}
if ($mid) {
//Prepare the message parameters and send the alert.
$subject = "Page not found";
$msg = "Someone tried to access document id $docid";
$modx->sendAlert("Error",$mid,0,$subject,$msg,0);
}
//Build the URL with the search parameter.
$url=$modx->makeUrl($pg,'','&AS_search='.$docid);
//Redirect to the 404 page.
$modx->sendRedirect($url);
exit;
}
break;
default :
return; // stop here
break;
}

