NYCPHP Meetup

[nycphp-talk] Dynamically Add Links to Text

Randal Rust randalrust at gmail.com
Thu Aug 27 10:04:18 EDT 2009


In one of our applications, we have a need to apply inline links to
the text, and would like to figure out a way to do this dynamically. I
have looked for this high and low, but haven't been able to find what
I am looking for. Perhaps I am searching the wrong keywords.

What we have is a repository of 1,000 articles. Each article has a
unique title. If the title of that article appears in another article,
we want to apply a link to the text, but only the first instance of
the text.

My thought is that we have to:

1. create an array of all titles
2. create a variable that holds the article text
3. loop through the title array and search the article text for a match
4. the first instance that a match is found, append the link and
update the string variable

The trick is that when a new article is added, they system needs to
automatically go back to all of the existing articles and run through
this process, which I don't like, because this won't be 100% accurate
in the editor's eyes. each updated article needs to be reviewed. I
also think it would cause a performance hit and dramatically slow down
the system, especially in one installation where we have nearly 4,000
record that would need to be updated.

Personally, it seems to me that JavaScript is a better solution here,
and to simply append those links when the page loads. Unfortunately,
these sites all have to comply with Section 508 and other
accessibility guidelines, so that might not be an acceptable solution.

Any suggestions?

-- 
Randal Rust
R.Squared Communications
www.r2communications.com
614-370-0036



More information about the talk mailing list