Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-07-11 20:06:59

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Highlight certain words - PHP? Javascript?

I’m working on a website for a friend and I have been asked if it is possible to automatically highligt certain words. For example they want “body” in bodyflow, bodypump and so on to be red letters. There must be a way to get the “body”-part of these words enclosed in span tags with a css-class, but I dont know how.

Anybody who can help or know where I might find help?


Textpattern n00b

Offline

#2 2008-07-11 20:37:33

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: Highlight certain words - PHP? Javascript?

Links, images and phrase modifiers normally require surrounding whitespace.

this*won't*work = this*won’t*work

To use these without whitespace, surround the modifier with [] square brackets.

this[*will*]work = thiswillwork

This is particularly useful in conjunction with superscript and subscript.

The same applies to % for spans. See the textile reference for more infos.


TXP Builders – finely-crafted code, design and txp

Offline

#3 2008-07-11 20:41:21

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Re: Highlight certain words - PHP? Javascript?

I was thinking of a way to automatically do this, that is without having to do it in textile?


Textpattern n00b

Offline

#4 2008-07-11 20:44:50

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,599
Website

Re: Highlight certain words - PHP? Javascript?

Oh right, maybe an7_filter will do what you do. Not tried it myself, though.

EDIT: From the examples yes, looks like it does just what you want.

Last edited by jakob (2008-07-11 20:46:08)


TXP Builders – finely-crafted code, design and txp

Offline

#5 2008-07-11 20:56:16

Mr. Smith
Member
From: Denmark
Registered: 2006-11-10
Posts: 56

Re: Highlight certain words - PHP? Javascript?

That looks pretty cool, I will give it a try tomorrow! Thanks Jakob.


Textpattern n00b

Offline

Board footer

Powered by FluxBB