Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
[plugin] [ORPHAN] etz_hilite
Highlights search terms inside your pages.
Usage:
- Wrap the part of the page you want to highlight between
<txp:etz_hilite>
and</txp:etz_hilite>
. - Put
span.etz_hilite {color: yellow;}
or whatever in your CSS.
Additional options:
- class defaults to “etz_hilite”
Known bugs/limitations:
- Does not support multibyte encodings (including Unicode) yet.
- Ignores quotes in search terms.
- Only supports Google and Textpattern’s own search for the moment.
Notes:
Currently it’s of little use to me because it doesn’t support UTF-8, but it should be usefult to you that use 100% Latin scripts. I plan to extend its functionality in the future. Feedback is most appreciated.
Last edited by Etz Haim (2005-07-30 18:00:47)
VC3 :: weblog :: my wishlist
Offline
Offline
Re: [plugin] [ORPHAN] etz_hilite
> soulship wrote:
> This sounds really cool. Will this work in an artilce form?
Sure, it will work anywhere you put it. I actually use mine inside an article form.
VC3 :: weblog :: my wishlist
Offline
Re: [plugin] [ORPHAN] etz_hilite
Etz,
A while back I wrote an extensible search-highlighting script (had it supporting twenty or so different search engines last I checked) that I’ve been meaning to turn into a TXP plugin; would you have any objection to my using your plugin as a basis for that? You would, of course, be credited.
You cooin’ with my bird?
Offline
Offline
Re: [plugin] [ORPHAN] etz_hilite
Currently it’s of little use to me because it doesn’t support UTF-8
That makes me sad. I wish UTF-8 were supported.
Offline
Re: [plugin] [ORPHAN] etz_hilite
Etz: cool. I’ll try to have a first draft in about a week.
You cooin’ with my bird?
Offline
Re: [plugin] [ORPHAN] etz_hilite
With the following changes to the final function in the code, etz_hilite will use the new HTML5 mark
tag as standard, e.g. to have your search term highlighted as <mark>term</mark>
, use:
<txp:etz_hilite><txp:body /></txp:etz_hilite>
If you still want your terms wrapped in <span class="hilite">term</span>
, then use:
<txp:etz_hilite wraptag="span" class="hilite"><txp:body /></txp:etz_hilite>
This is the changed final function of the plugin:
function etz_hilite ($atts, $thing) {
if (is_array($atts)) extract($atts);
if (!(isset($wraptag))) $wraptag = "mark";
if (!(isset($class))) {$class = "";} else {$class=' class="'.$class.'"'; }
if (!(isset($keywords))) $keywords = etz_getkeywords();
$output = parse($thing);
if ($keywords != NULL) {
$keywords_split = explode(' ', $keywords);
foreach ($keywords_split as $etz_keyword) {
$h = new Highlight ($etz_keyword,'<'.$wraptag.$class.'>{keyword}</'.$wraptag.'>');
$output = $h->process($output);
}
}
return $output;
}
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1