I know in wikipedia.org there is links to diffrent topics all over the pages. There is also a wordpress plug in that do the same. Is there any PHP script that can do this on my normal pages if i want to link special words to special places.
I think it using database to store the keyword and link then with regex function, replace the keyword with patern
I am no sure about wikipedia, how exactly it displays. But, for example your page code in varible $data. You can do this $replaces = Array( 'windows' => "http://www.microsoft.com", 'linux' => "http://www.gnu.org", 'scripts' => "http://www.digitlpoint.com", 'articles' => "http://www.apitalk.com" ); #now make replacemnts foreach($replaces as $k => $v) $data = str_replace($k, "<a href='$v' target=_blank>$k</a>", $data); Code (markup): Then you my utilize the data contained in $data which will be highlighting the the words as links. regards
This wil lbe basecode, besides if you are fetching pages data from database then simply make a page that accepts row id as document.php?id=124 where 124 will be the row id in table, getch it and put data in $data adn follow the same code. regards
You will need to add this to every page, or more precisely every output you want the keywords to be replaced at. Of cause you could also run a script that replaces all the words in the content with links in the database (which would be faster, but definitely way more inconvenient).
If it's only 20 pages then yes. But if you want to add another keyword you would again have to manually go through all the 20 pages again and that can get pretty boring over time.
Solution to such problem is simple keep the arrayin separate file and include it in the pages. Or maintain the keywords and relative links in a text file or database. I would suggest a separte php file that is included in the 20 pages. Besides if it is comming from database, why do you need 20 pages actually ? One pag can serve the purpose, or is the strucutre of each page different? regards