Go Back   PHP Link Directory Forum > PHP Link Directory (phpLD) > Mods and contribution Discussion

Mods and contribution Discussion This forum is only for discussion of modding phpLD. For specific mod releases, please see the appropriate forum.

Closed Thread
 
Thread Tools Display Modes
Old 09-28-2005   #1
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default [Highlight Search Terms] Mod

The following mod will highlight terms in the search results page. As easy as 1-2-3:

Step 1
Open templates/link.tpl:

Find:

Code:
{strip}
Add the following before:

Code:
{assign var="title" value=$link.TITLE}
{assign var="desc" value=$link.DESCRIPTION}
{php}
if ($this->get_template_vars('search') and $this->get_template_vars('search') != ".") {
    $title_highlighted = eregi_replace($this->get_template_vars('search'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('search') . "</b>", $this->get_template_vars('title'));
    $this->assign('title_highlighted', $title_highlighted);
    $desc_highlighted = eregi_replace($this->get_template_vars('search'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('search') . "</b>", $this->get_template_vars('desc'));
    $this->assign('desc_highlighted', $desc_highlighted);
}
else {
    $this->assign('title_highlighted', $this->get_template_vars('title'));
    $this->assign('desc_highlighted', $this->get_template_vars('desc'));
}
{/php}
Step 2
Find:

Code:
{$link.TITLE}
Replace with:

Code:
{$title_highlighted}
Step 3
Find:

Code:
{$link.DESCRIPTION}
Replace with:

Code:
{$desc_highlighted}
[UPDATE:] change 'term' to 'search' in first code block to use this mod for phpLD 3.04+


Cheers,

Dan
Virtual Solutions
monster-submit.com

Last edited by VSDan; 12-23-2006 at 08:38 PM.
VSDan is offline  
Old 09-28-2005   #2
Sharr76
 
Join Date: Jul 2005
Posts: 73
Send a message via MSN to Sharr76
Default

Can we see this working?
Sharr76 is offline  
Old 09-28-2005   #3
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

Sure can: go to the following URL, and enter webmaster as search term:

http://www.monster-submit.com/directory/


Cheers,

Dan
Virtual Solutions
monster-submit.com
VSDan is offline  
Old 12-09-2005   #4
Neticus
Supporter
 
Neticus's Avatar
 
Join Date: Dec 2005
Posts: 487
Default

Thanks for a great mod everything works as instructed. Yet I seem to be having the problem of words being over-highlighted.
For instance a search for 'hosting' finds 'Linux hosting' - hosting will be highlighted but the space before it will also be highlighted along with the word. This over-highlighting poses problems as the process dosen't seem to recognise 'hosting' if 'linuxhosting' is placed together as one word.

I don't understand maybe its me any help much appreciated, thanks
Neticus
Neticus is offline  
Old 12-09-2005   #5
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

Hi Neticus:

I don't have that problem myself. Can you provide URL to your directory so I can check.
__________________
Dan

Unlock the Vault Contest :: Over $350 Prizes!
phpLD Mods :: phpLD_Vault
Webmaster Resources Directory
phpLD_Vault Support

IMPORTANT NOTE:
phpLD_Vault Support not handled in this forum AND not via PM here. Click on link above for support. NO exceptions!
VSDan is offline  
Old 12-10-2005   #6
Neticus
Supporter
 
Neticus's Avatar
 
Join Date: Dec 2005
Posts: 487
Default

Hi VSDan, have figured it out as suspected it was a problem from my side. Sorry my bad!

What it was was I had removed 'Search Results for: ' in the following code in index.php, Yet had also left a space inbetween the commas when I did so, thus ' ' when it should have been '' . That space was also being processed as part of the search hence the over-highlighting effect.

Code:
$path[] = array ('ID' => '0', 'TITLE' => _L('Search Results'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Search Results for: ').$_REQUEST['q']);
Although I have also now discovered that the highlight dosen't work even when the full 'Search Results for: ' text is in place. For me the highlight only works when that field is blank and left as '' I don't know why, its like the highlight code is taking the text in DESCRIPTION field as part of the search.

So thats the downlow!

Again thanks for the reply.
Cheers Neticus.
Neticus is offline  
Old 12-31-2005   #7
angeljs
Supporter
 
Join Date: Oct 2005
Posts: 42
Default

I can't seem to get this working...I've added the code as supplied, but the search terms won't highlight
:(
angeljs is offline  
Old 01-13-2006   #8
angeljs
Supporter
 
Join Date: Oct 2005
Posts: 42
Default

Any idea what the problem could be? :?:
angeljs is offline  
Old 01-13-2006   #9
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

Is this where it is being used:

http://www.compact-hosting.co.uk/php/

Can you post your link.tpl.
__________________
Dan

Unlock the Vault Contest :: Over $350 Prizes!
phpLD Mods :: phpLD_Vault
Webmaster Resources Directory
phpLD_Vault Support

IMPORTANT NOTE:
phpLD_Vault Support not handled in this forum AND not via PM here. Click on link above for support. NO exceptions!
VSDan is offline  
Old 01-13-2006   #10
angeljs
Supporter
 
Join Date: Oct 2005
Posts: 42
Default

Sure, thanks:

Code:
{assign var="term" value=$category.DESCRIPTION} 
{assign var="title" value=$link.TITLE} 
{assign var="desc" value=$link.DESCRIPTION} 
{php} 
if ($this->get_template_vars('term')) { 
   $title_highlighted = eregi_replace($this->get_template_vars('term'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('term') . "[/b]", $this->get_template_vars('title')); 
   $this->assign('title_highlighted', $title_highlighted); 
   $desc_highlighted = eregi_replace($this->get_template_vars('term'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('term') . "[/b]", $this->get_template_vars('desc')); 
   $this->assign('desc_highlighted', $desc_highlighted); 
} 
else { 
   $this->assign('title_highlighted', $this->get_template_vars('title')); 
   $this->assign('desc_highlighted', $this->get_template_vars('desc')); 
} 
{/php} 

{strip}
<table><tr>
{* show page rank *}
{if $smarty.const.SHOW_PAGERANK}
	<td>
	<p style="clear: both">{include file="pagerank.tpl" pr=$link.PAGERANK}
	</td>
{/if}

<td>
<a id="{$link.ID}" href="{$link.URL}"
{* nofollow *}
{if $link.NOFOLLOW or ($link.RECPR_VALID eq 0 and 
	($smarty.const.RECPR_NOFOLLOW eq 2 or 
	($smarty.const.RECPR_NOFOLLOW eq 1 and $link.RECPR_REQUIRED eq 1)))
    } rel="nofollow"
{/if}{if $smarty.const.ENABLE_BLANK} target="_BLANK"{/if}{if $smarty.const.ENABLE_DISPLAYURL} onMouseOver="self.status='{if $link.DISPLAYURL ne ''}{$link.DISPLAYURL}{else}{$link.URL}{/if}'; return true" onMouseOut="self.status=''; return true"{/if}>

{$title_highlighted}</a> <span class="url">- {if $smarty.const.ENABLE_DISPLAYURL and $link.DISPLAYURL ne ''}{$link.DISPLAYURL}{else}{$link.URL}{/if}</span>



{$desc_highlighted}
{if $link.RATE_ENABLED eq 1}
<span class="url">(Hits:{$link.HITS} Rating:{if $link.RATE eq '10.00'}[img]images/20.gif[/img] 
{elseif $link.RATE eq '0.00'}[img]images/0.gif[/img] 
{elseif $link.RATE eq ''}[img]images/0.gif[/img] 
{elseif $link.RATE le '0.50'}[img]images/1.gif[/img] 
{elseif $link.RATE le '1.00'}[img]images/2.gif[/img] 
{elseif $link.RATE le '1.50'}[img]images/3.gif[/img] 
{elseif $link.RATE le '2.00'}[img]images/4.gif[/img] 
{elseif $link.RATE le '2.50'}[img]images/5.gif[/img] 
{elseif $link.RATE le '3.00'}[img]images/6.gif[/img] 
{elseif $link.RATE le '3.50'}[img]images/7.gif[/img] 
{elseif $link.RATE le '4.00'}[img]images/8.gif[/img] 
{elseif $link.RATE le '4.50'}[img]images/9.gif[/img] 
{elseif $link.RATE le '5.00'}[img]images/10.gif[/img] 
{elseif $link.RATE le '5.50'}[img]images/11.gif[/img] 
{elseif $link.RATE le '6.00'}[img]images/12.gif[/img] 
{elseif $link.RATE le '6.50'}[img]images/13.gif[/img] 
{elseif $link.RATE le '7.00'}[img]images/14.gif[/img] 
{elseif $link.RATE le '7.50'}[img]images/15.gif[/img] 
{elseif $link.RATE le '8.00'}[img]images/16.gif[/img] 
{elseif $link.RATE le '8.50'}[img]images/17.gif[/img] 
{elseif $link.RATE le '9.00'}[img]images/18.gif[/img] 
{elseif $link.RATE le '9.50'}[img]images/19.gif[/img] 
{else}[img]images/20.gif[/img] 
{/if} 
  Votes:{$link.RATE_COUNT}) <a href=
	"{$smarty.const.DOC_ROOT}/rate.php?id={$link.ID}"><font size=1>Rate</a></span>{/if} | <font size=1>Report | <font size=1>Refer</p>


</p>
</td>
</tr></table>
{/strip}
Yes, the site below is where I have it.
angeljs is offline  
Old 01-13-2006   #11
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

This could take some debugging. Can you send me your FTP access information? If so, then you can send c/o support at monster-submit dot com
__________________
Dan

Unlock the Vault Contest :: Over $350 Prizes!
phpLD Mods :: phpLD_Vault
Webmaster Resources Directory
phpLD_Vault Support

IMPORTANT NOTE:
phpLD_Vault Support not handled in this forum AND not via PM here. Click on link above for support. NO exceptions!
VSDan is offline  
Old 01-23-2006   #12
m_leefs
 
Join Date: Jan 2006
Posts: 5
Default

Along with angeljs I also added the code as supplied, but the search terms won't highlight. I also just installed phpLD and everything else seems to work great. I tried to do some debugging, but as a newby without too much php experience I'm trying my best. I did find that the following

Code:
$this->get_template_vars('term')
contains "Search results for: term" so the code given will only highlight text that contains the following:

Search results for: term

But will not highlight just "term". The search though pulls out all links with "term" in them. So in a list I have the following highlights:

This is a link with the word term, which won't highlight, but Search results for: term will highlight. Weird huh.

Any help would be great. Thanks!
m_leefs is offline  
Old 01-23-2006   #13
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

Can you post your index.php and main.tpl files.
__________________
Dan

Unlock the Vault Contest :: Over $350 Prizes!
phpLD Mods :: phpLD_Vault
Webmaster Resources Directory
phpLD_Vault Support

IMPORTANT NOTE:
phpLD_Vault Support not handled in this forum AND not via PM here. Click on link above for support. NO exceptions!
VSDan is offline  
Old 01-25-2006   #14
VSDan
Supporter
Moderator
 
VSDan's Avatar
 
Join Date: Sep 2005
Location: Vancouver, BC, Canada
Posts: 1,180
Default

I think I see the problem (should have mentioned in my instructions). In index.php, change:

Code:
$path[] = array ('ID' => '0', 'TITLE' => _L('Search Results'), 'TITLE_URL' => '', 'DESCRIPTION' => _L('Search results for: ').$_REQUEST['q']);
to:

Code:
$path[] = array ('ID' => '0', 'TITLE' => _L('Search Results'), 'TITLE_URL' => '', 'DESCRIPTION' => $_REQUEST['q']);
__________________
Dan

Unlock the Vault Contest :: Over $350 Prizes!
phpLD Mods :: phpLD_Vault
Webmaster Resources Directory
phpLD_Vault Support

IMPORTANT NOTE:
phpLD_Vault Support not handled in this forum AND not via PM here. Click on link above for support. NO exceptions!
VSDan is offline  
Old 01-26-2006   #15
m_leefs
 
Join Date: Jan 2006
Posts: 5
Default

Thanks VSDan for the fix! I also added some extras in order to highlight multiple word searches (seperated by spaces).

replace
Code:
if ($this->get_template_vars('term')) {
   $title_highlighted = eregi_replace($this->get_template_vars('term'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('term') . "</b>", $this->get_template_vars('title'));
   $this->assign('title_highlighted', $title_highlighted);
   $desc_highlighted = eregi_replace($this->get_template_vars('term'), "<b style='background-color: red; color: #FFFFFF;'>". $this->get_template_vars('term') . "</b>", $this->get_template_vars('desc'));
   $this->assign('desc_highlighted', $desc_highlighted);
}
with
Code:
if ($this->get_template_vars('term')) {
   $term_array = explode(" ", $this->get_template_vars('term'));
   $title_highlighted = $this->get_template_vars('title');
   $desc_highlighted = $this->get_template_vars('desc');
   for ($i =0; $i<count($term_array); $i++){
       $title_highlighted = eregi_replace($term_array[$i], "<b style='background-color: red; color: #FFFFFF;'>".$term_array[$i]."[/b]", $title_highlighted);
       $this->assign('title_highlighted', $title_highlighted);
       $desc_highlighted = eregi_replace($term_array[$i], "<b style='background-color: red; color: #FFFFFF;'>".$term_array[$i]. "[/b]", $desc_highlighted);
       $this->assign('desc_highlighted', $desc_highlighted);
   }
}
Doing this I noticed a bug in the search function when searching multiple words. The search is dependent on the order of the words, however when searching multiple words one may not want that. Example: Searching "great site" will find links like "This is a great site", but not "This site is great". Any insight anybody could give would be great. Thanks.

Last edited by VSDan; 07-30-2006 at 07:41 PM.
m_leefs is offline  
Old 02-06-2006   #16
John D
 
Join Date: Nov 2005
Posts: 156
Default

Hey,
This doesn't seem to highlight it for me..

Try a search on www.AllDotNet.com - Don't see any differences.

Thanks
John D is offline  
Old 02-06-2006   #17
Neticus
Supporter
 
Neticus's Avatar
 
Join Date: Dec 2005
Posts: 487
Default

Quote:
Originally Posted by John D
Hey,
This doesn't seem to highlight it for me..

Try a search on www.AllDotNet.com - Don't see any differences.

Thanks
Have you tried this yet?:
http://www.phplinkdirectory.com/foru...hp?p=9284#9284
Neticus is offline  
Old 02-06-2006   #18
John D
 
Join Date: Nov 2005
Posts: 156
Default

Thanks a lot

There were that many replies with different fixes I read it a few times but still missed a lot
John D is offline  
Old 03-23-2006   #19
LyndaLAX
Supporter
 
Join Date: Mar 2006
Posts: 22
Default does this work in v3.03?

thanks,
Lynda
LyndaLAX is offline  
Old 07-30-2006   #20
angeljs
Supporter
 
Join Date: Oct 2005
Posts: 42
Oh, dear, now look what's happened:
http://www.shop4bizness.com/mall/index.php?q=art
angeljs is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:58 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.