[nycphp-talk] Dynamically Add Links to Text

Chuck Reeves chuck.reeves at
Thu Aug 27 10:17:15 EDT 2009

I think the best way to tackle this would be look for titles of articles
when you posting a new article and just update the text when the editor is
going to save the article.  Since you can store the title of articles as a
field in your database, you can then go and quickly find if the article
contains the title and just do a simple replace.

Using JS is not going to work to your advantage since the dosent need to be
dynamic all the time (that can also lead to bugs).  Just update the article
at the time of saving saves processes in the long run and prevents cross
browser issues that can come up in JS.

On Thu, Aug 27, 2009 at 10:04 AM, Randal Rust <randalrust at> wrote:

> 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
> 614-370-0036
> _______________________________________________
> New York PHP User Group Community Talk Mailing List
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the talk mailing list