SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: keywords into links
-
Sep 16, 2007, 06:53 #1
- Join Date
- Jan 2005
- Location
- UK
- Posts
- 539
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
keywords into links
I want to design a script that allows me to add dynamic links to certain keywords (will provide links via php).
I have been searching for ages now, looking for a js snippet that will read a page and add links to certain keywords...
Anyone know of any? How would i do it?
-
Sep 16, 2007, 07:39 #2
- Join Date
- Jan 2007
- Location
- Belgium
- Posts
- 591
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'd use PHP for this.
-Using ob_start('myReplacer');
-A function myReplacer where you get all the contents of the page using ob_get_contents(), after getting the contents clean the output buffer using ob_clean();
-A preg_replace statement to separate the body from the rest
-A loop to cycle through a bunch of keywords (using a database containing a number of links and keywords associated with the links).
-Within the loop use preg_replace to replace all occurences of a keyword with a link -if the keyword is not in a link yet or between any tags.FOR SALE: 1 set of morals, never used, will sell cheap
-
Sep 16, 2007, 07:44 #3
- Join Date
- Jan 2005
- Location
- UK
- Posts
- 539
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Unfortunately, it needs to be javascript as it will ultimately be included via an external js file...there will be php processing in the background to determine what link for what keyword, but the links need to be added client-side...
Bookmarks