@4hero
In fact, the "Results with images" demo had a typo error: &highlightResult
s=`0` instead of &highlightResult=`0`.
This probably explain why you didn’t get the results.
But let me try to explain how is set up this demo.
The snippet call:
[!AjaxSearch? &extract=`99` &extractLength=`120` &ajaxMax=`3` &showMoreResults=`1` &moreResultsPage=`176` &config=`image` &searchWordList=`enSearchWordList` &highlightResult=`0` &tplLayout=`optionMultipleList`!]
&extract=`99` : means that for a document where you found a search term you allow to display a maximum of 99 extracts. I put 99 to be upper of 9 but here 9 is largely enought. By default, extract is here a concatenation of the content and tv values of document. So &extract=`99` = &extract=`99:content,tv_content`
&extractLength=`120` : we limit the size of the extract to 120 characters
&ajaxMax=`3` &showMoreResults=`1`&moreResultsPage=`176` : means you want a maximum of 3 results and a link "show more results" to go to the moreResultsPage (#176).
&config=`image` : instead of use the "defaut" configuration file, you specify the use of a file named "image.config.php. This file is located into the ajaxSearch/configs folder
&searchWordList=`enSearchWordList` : here you indicate that the list of search terms will be provided by the function "enSearchWordList". This function shoud be defined in the configuration file (image.config.php).
&highlightResult=`0` : you don’t want highlight the results.
The "image.configuration.php" file is the following:
<?php
$__stripOutput = 'saveImage';
// 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 saveImage($results){
// replace line Breaking by space
$results = stripLineBreaking($results);
// strip other html tags
$results = stripHtmlExceptImage($results);
// strip javascript tags
$results = stripJscripts($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 enSearchWordList(){
$list = "guatemala,samassekou,equateur,cromer,zatreanu,burnett";
return $list;
}
?>
I have kept the comments for stripOutput and searchWordList (the lines beguin by //)
the first relevant line is:
$__stripOutput = 'saveImage';
that means that the default stripOutput function to use will be the "saveImage" function.
The "saveImage" function is defined in the configuration as follow:
function saveImage($results){
// replace line Breaking by space
$results = stripLineBreaking($results);
// strip other html tags
$results = stripHtmlExceptImage($results);
// strip javascript tags
$results = stripJscripts($results);
return $results;
}
$results = stripLineBreaking($results); : first all the line breaking characters inside the results are replaced by a space character. the stripLineBreaking is provided by ajaxSearch and could be use in any user function.
$results = stripHtmlExceptImage($results); : then we strip all the html tags except the <img .... > tag. stripHtmlExceptImage($results); as stripLineBreaking function could be called in any custom stripOutput user function
$results = stripJscripts($results); : and finally we strip all potentials javascript call, by calling the stripJscripts function.
With this stripOutput function we have filtered all the unwanted characters and tags and only save the image tags.
Nevertheless, we are obliged to forbid the highlighting otherwise we will break the <img ... > tag by adding the necessary tag to highlight the results.
the enSearchWordList defined in the image.configuration.php simply return a list of words that will be use to do a search. These word are labels of image like for instance :
<img alt="equateur01_250.jpg" src="assets/images/uc2007/n10/equateur01_250.jpg" width="250" />
I hope that these explanations help you to understand how runs this first draft of "results with images" demo.