PDA

View Full Version : Display Document Icon in Result-page


Topaz
11-16-2004, 02:03 PM
Hi,

for those who may wont to display an icon if the search-result links to a binary document like word, pdf or anything else, I am adding here a small mod I inserted into "search_function.php" right after the line $timer->stop('Extracts');. Also these binaries will be opened in a new browser-window.


//binaries should display an image and be opened in a new window
$suffix_array = array('doc','pdf','xls','zip','ppt','pps');
$suffix = substr($url,-3);
if (in_array($suffix, $suffix_array)) {
$mytarget = '_blank';
$myimage = '<img src="icons/'.$suffix.'.gif" hspace="4">';
} else {
$mytarget = LINK_TARGET;
$myimage = '';
}


As you can see, I installed an "icons"-folder in the "search"-directory.

And I had to alter the code for the table_results array (just underneath). The value for "page_link" looks now

'page_link' => $myimage."<a class=\"phpdig\" href=\"".$url."\" onmousedown=\"return clickit(".$n.",'".$js_url."')\" target=\"".$mytarget."\" >".ereg_replace('%20*',' ',$title)."</a>",

According to this example the names of the icons should be like "pdf.gif" or "doc.gif".

Topaz