![]() |
| |||||||
| Mods and contribution Discussion This forum is only for discussion of modding phpLD. For specific mod releases, please see the appropriate forum. |
![]() |
| | Thread Tools | Display Modes |
| | #1 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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} 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} Find: Code: {$link.TITLE} Code: {$title_highlighted} Find: Code: {$link.DESCRIPTION} Code: {$desc_highlighted} Cheers, Dan Virtual Solutions monster-submit.com Last edited by VSDan; 12-23-2006 at 08:38 PM. |
| |
| | #2 |
| Can we see this working? | |
| |
| | #3 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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 |
| |
| | #4 |
| Supporter Join Date: Dec 2005 Posts: 487 | 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 |
| |
| | #5 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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! |
| |
| | #6 |
| Supporter Join Date: Dec 2005 Posts: 487 | 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']); So thats the downlow! Again thanks for the reply. Cheers Neticus. |
| |
| | #7 |
| Supporter Join Date: Oct 2005 Posts: 42 | I can't seem to get this working...I've added the code as supplied, but the search terms won't highlight :( |
| |
| | #8 |
| Supporter Join Date: Oct 2005 Posts: 42 | Any idea what the problem could be? :?: |
| |
| | #9 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | __________________ 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! |
| |
| | #10 |
| Supporter Join Date: Oct 2005 Posts: 42 | 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} |
| |
| | #11 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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! |
| |
| | #12 |
| Join Date: Jan 2006 Posts: 5 | 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') 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! |
| |
| | #13 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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! |
| |
| | #14 |
| Supporter Moderator Join Date: Sep 2005 Location: Vancouver, BC, Canada Posts: 1,180 | 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']); 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! |
| |
| | #15 |
| Join Date: Jan 2006 Posts: 5 | 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);
} 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);
}
} Last edited by VSDan; 07-30-2006 at 07:41 PM. |
| |
| | #16 |
| Join Date: Nov 2005 Posts: 156 | Hey, This doesn't seem to highlight it for me.. Try a search on www.AllDotNet.com - Don't see any differences. Thanks |
| |
| | #17 | |
| Supporter Join Date: Dec 2005 Posts: 487 | Quote:
http://www.phplinkdirectory.com/foru...hp?p=9284#9284 | |
| |
| | #18 |
| Join Date: Nov 2005 Posts: 156 | Thanks a lot ![]() There were that many replies with different fixes I read it a few times but still missed a lot |
| |
| | #19 |
| Supporter Join Date: Mar 2006 Posts: 22 | thanks, Lynda |
| |
| | #20 |
| Supporter Join Date: Oct 2005 Posts: 42 | Oh, dear, now look what's happened: http://www.shop4bizness.com/mall/index.php?q=art |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|