-
dynamic text to links
is it possible to have something where, whenever a particular word is written in my forum, it is turned into a link. I would like to do this for advertising. If someone mentions a product, that word automatically become a link to the manufacturers product information web site.
Cheers!
-
-
Complex.
You could use php for this.
str_replace($text," product ",' <a href="product.com">product</a> ');
That should replace all instances of product with a link.
You would also want to account for using Product, PRODUCT, etc. if that mattered to you.
Additionally, using " product " and " <a ..../a> " is good 'cause you would have spaces around it, rather than replacing, for example, "biproduct", or some similar word that contain the word.... it will only do full words. (You could be more creative here, too.)
Just repeat for each product/etc.
However....
Here's the tricky part--
You would need to do this to a VARIABLE, not just the "whole page".
So... find some way of storing the html for the whole page as a variable in php.... either when it's taken from the database, etc.
Are you using a forum? You could just add this into the forum's existing code for formatting posts. It would be almost identical to the process used for emoticons.
The hard part is getting the page as a variable, not replacing the words... that's easy enough.
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
Hi djr33
I am using phpnuke. I would like to do this in the forums which are the phpbb2 Port by Tom Nitzschner. I'm not too code savy so I really apprciate your help here.
It would be ideal if it supported upper or lower case ( Sebatron or sebatron). and only write the link to the exact word. I have it working by using the forums word censor option however, it also rewrite/ links the word in the topic title. When it does that it breaks the original link of the topic. I only want this to work in the posts, not topic titles. If I could use this censor function for this and find a way to comment out it from including the title I'd possibly have it.
-
-
You have to look through the source code and find where that function is, then add in custom php. It's hard to search through there... it's a maze.
Get to it
Daniel -
Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
-
-
Could I simply add ( activate, deactivate, modify) something in phpMyAdmin and exclude titles ?
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks