Forum Moderators: coopster

Message Too Old, No Replies

Automatic links for key words

         

s9901470

12:40 pm on Feb 18, 2006 (gmt 0)

10+ Year Member



Hi

I have a site with a large number of pages, and want to use PHP to automatically cross-link them using key words.

For example, whenever the word 'contact' appears, I want it to automatically link to the 'contact' page.

Because there are 100+ different pages, I don't want to have to edit the links manually.

any suggestions would be most welcome

Thanks in advance

coopster

3:44 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Read the entire source into a string and find/replace the keywords with a url. One way to accomplish this might be to use PHP's output control functions. There is an example on the ob_start() [php.net] page that might get you started.

s9901470

2:11 pm on Feb 27, 2006 (gmt 0)

10+ Year Member



I don't want to do search/replace because the content of every page in stored in a MySQL database. Is there a way to add the key words after they have been pulled from the database, and turn them into links?

coopster

2:27 pm on Feb 27, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The method just described is exactly that. You would read the value from the database table into a string variable and do a find/replace on keywords in that string.