View Single Post
Old 10-05-2003, 11:03 PM   #1
bthurlow
Green Mole
 
Join Date: Oct 2003
Location: Mississippi, USA
Posts: 7
Lightbulb a more google approach

Hey all, I have made some modifications to my phpdig search. Some of you will like some will not.

I had some problems with the highlighting of the search terms so i had to make a workaround that i have implemented. Also, I wanted a more google styled look to my search engine. To accomplish this i again did some coding. Granted most of this is a rough version it is throughly tested for stability. Below is the files and the coding changes to them. Maybe this will even make it into the next version. If you all would like to include this functionality just let me know and i'll make a more user friendly configuration.

Code & Files.

Add the following to config.php just before the default values.

//Remove variable to not use functionality
define('HIGHLIGHT','<b><font color="blue">'); //Highlight for non classic mode or if above highlight does not work
define('IMG_NAV_START_NOPREV','<img src="./tpl_img/d-nav.gif"/><img src="./tpl_img/r-nav.gif"/>'); //Image for beggining of Nav Bar w/o previous message
define('IMG_NAV_START_PREV','<img src="./tpl_img/r-nav.gif" border=0 align="right"/><img src="./tpl_img/d-nav.gif" border=0 align="right"/><br><br>'); //Image for beggining of Nav Bar w/ previous message
define('IMG_NAV_PAGE_NOSEL','<img src="./tpl_img/a-nav.gif" border=0><br><br>'); //Image for noncurrent nav bar page
define('IMG_NAV_PAGE_SEL','<img src="./tpl_img/a-nav-sel.gif"><br><br>'); //Image for current nav bar page
define('IMG_NAV_END_NONEXT','<img src="./tpl_img/c-nav.gif" align="left"/><img src="./tpl_img/o-nav.gif" align="left"/>'); //Image for end of nav bar w/o next message
define('IMG_NAV_END_NEXT','<img src="./tpl_img/c-nav.gif" border=0 align="left"/><img src="./tpl_img/o-nav.gif" border=0 align="left"/><br><br>'); //Image for end of nav bar w/ next message

Replace Line 150 in your phpdig_functions.php file with this:
return @eregi_replace($ereg,'\\1<span class=\"phpdigHighlight\">'.HIGHLIGHT.'\\2</b></font></span>\\3',$string);

In search_function.php replace lines 346 - 369 with the following.

if ($lim_start > 0) {
$previous_link = $url_bar.($lim_start-$limite);
$nav_bar .= '<td><a class=\"phpdig\" href="'.$previous_link.'" >'.IMG_NAV_START_PREV.'<center>&lt;&lt;'.phpdigMsg("previous").'</a></td>';
}
else{
$nav_bar .= '<td valign="top">'.IMG_NAV_START_NOPREV.'</td>';
}
$tot_pages = ceil($num_tot/$limite);
$actual_page = $lim_start/$limite + 1;
$page_inf = max(1,$actual_page - 5);
$page_sup = min($tot_pages,max($actual_page+5,10));
for ($page = $page_inf; $page <= $page_sup; $page++) {
if ($page == $actual_page) {

$nav_bar .= ' <td><span class=\"phpdigHighlight\">'.IMG_NAV_PAGE_SEL.HIGHLIGHT.$page.'</font></span></img></td>';
$pages_bar .=' <td><span class=\"phpdigHighlight\">'.HIGHLIGHT.$page.'</font></span></td>';
$link_actual = $url_bar.(($page-1)*$limite);
}
else {
$nav_bar .= '<td><a class=\"phpdig\" href="'.$url_bar.(($page-1)*$limite).'" >'.IMG_NAV_PAGE_NOSEL.$page.'</a></td>';
$pages_bar .= "<td><a class=\"phpdig\" href=\"".$url_bar.(($page-1)*$limite)."\" >$page</a> \n</td>";
}
}

if ($more_results == 1) {
$next_link = $url_bar.($lim_start+$limite);
$nav_bar .= '<td><a class=\"phpdig\" href="'.$next_link.'" >'.IMG_NAV_END_NEXT.'<center>'.phpdigMsg("next").'&gt;&gt;</a></td>';
}
else{
$nav_bar .= '<td valign="top">'.IMG_NAV_END_NONEXT.'</td>';
}

if you would like to comment on these modifications please feel free to do so. Hopefully some of you will find this interesting and usefull.

Sincerely,
Thurlow
bthurlow is offline   Reply With Quote