Forum Moderators: coopster

Message Too Old, No Replies

dynamic links based on keyword library

automatic link generator based on VISIBLE body content

         

8PDesign

6:29 pm on Jan 17, 2008 (gmt 0)

10+ Year Member



Hi,
I need to build a class to create dynamic links based on page content.

So I would have a library of about 150 Keyword/url pairs.
And I would need the script to run through the content and replace a keyword by <a href="url">keyword</a>

Of course we need to ignore anything that is in html tags so that a keyword like "title" or "table" does not replace HTML tags. And it would ignore ANY text that is already wrapped inside a link.

Example:
So we would have a keyword library:
"fun", "http://www.somelink.com"
"table", "http://www.sometablestore.com"
etc (about 100 keywords),

and the class would replace any instance of "fun" by <a href="http://www.somelink.com">fun</a>

Anyone knows a nice class for this?
We find a couple, but they were not perfect, and were very slow when we had a lot of keywords.

thanks all for your help

physics

1:04 am on Jan 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think a custom solution would be best and probably faster. Should be doable with a hash & regexes or a parser.