bb
|
Posted: 11/02/2003, 12:11 PM |
|
Recently freeware PHP code was posted at http://www.bodden.de/projects/php/.
It seems to do everything most of us would want. I've (unsuccessfully) tried to implement it in a grid. I'm hoping someone with more experience can figure out how to integrate it in a BeforeShowRow event and publish the results for all. It is also case-insensitive. Its description is:
"This PHP function lets you easily highlight e.g. search results on a specific website. Just pass the words to highlight, the path of the page (server path) and the color to highlight with. The extraordinary property about this function is that it manages not to perform replacements inside HTML tags (which could also include the word to highlight). NEW: Version 1.1 now features also highlighting in multiple colors for all different input tokens."
|
|
|
DaveRexel
|
Posted: 11/02/2003, 2:14 PM |
|
::
This was an excellent 3rd-party component for CCS!
It's easy to implement:
1- copy the highlight.php file to your CCS project
2- include it in your page
3- use the following example code in CCS Event with correct scope
(assuming a grid named myGrid, text control with HTML output named html_text and search control named s_keyword)
//-------------------
global $myGrid;
if (!isset($_REQUEST["s_keyword"])) {
$query_url=$_REQUEST["s_keyword"];
$keywords = explode(" ",$query);
$colors[0]='#FF66CC';
$colors[1]='#FFFF00';
$myGrid->html_text->SetValue(highlight_search($keywords,$myGrid->html_text->GetValue(),$colors));
}
//--------------------
Hope this helps
Dave
RexDesign CodeCharge Studio Tutorials http://www.rexdesign.com/ccs/default.php
|
|
|
DaveRexel
|
Posted: 11/02/2003, 2:31 PM |
|
::
an error crept into the above code (why doesn't this forum allow editing of posts)
anyway please correct the if-clause to read:
if (isset($_REQUEST["s_keyword"])) {
Dave
|
|
|
Zye
|
Posted: 11/02/2003, 4:59 PM |
|
Many thanks bb and DaveRexel
Great stuff :) I have been trying to find a solution for a while now.
I have Dave's code working but it highlights all the words in my text control 'news_content'
What am I missing ...
global $clubs;
if (isset($_REQUEST["s_list_name"])) {
$query_url=$_REQUEST["s_list_name"];
$keywords = explode(" ",$query);
$colors[0]='#FF66CC';
$colors[1]='#FFFF00';
$clubs->night_content->SetValue(highlight_search($keywords,$clubs->night_content->GetValue(),$colors));
Thanks again.
|
|
|
|