The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Text Replacement Links 1.1 (Updated!) Details »» | |||||||||||||||||||||||||
Text Replacement Links ==================== Author: Ken 'LiveWire' Iovino Site: www.vBhacks.us Version: 1.1 ==================== Updates
Huge Thanks I have to give a huge thanks to the following members that have helped me get this hack where it is now. Xenon, Kentaurus, nexialys, Geographic2, and lewekleonek. Thank you guys very much! What this does This will allow you to specified any text you add to automatically turn into a link when your members post the word. For example, you go to the ACP and add the word 'google' to the list and then you add the 'url' to googles website, and anytime a member post the word google, it will automatically turn it into a link. See screenshots for example. To do list...
Please read carefully and make all the necessary changes as stated. This is will work if installed properly. PLEASE REMEMBER TO BACKUP BEFORE YOU BEGIN! If you like this hack Click It Help & Support Before asking for support Please make sure you have done all necessary changes! If you still need support please post a reply here. Please post bugs and errors here. Hope you like, feedback welcomed. Special Thanks and Credit to -Xenon -Kentaurus -nexialys -Geographic2 -lewekleonek Show Your Support
|
Comments |
#52
|
|||
|
|||
this hack doesn't work at all..
|
#53
|
|||
|
|||
Somebody should continue to work on this. It's a really great option for advertisers. Not only does their banner ad show (if they have one), but any time their company name is addressed, it can link to their web site...
|
#54
|
||||
|
||||
The hack works great for me. But with the "spaces" addition it will not work if the word to be replaced is the first or last word in a post.
|
#55
|
|||
|
|||
Got it working with the code (case insensitive) posted by Geographic2.
One bug I noticed though -- it doesn't handle phrases. I can't replace 2 word phrases. So I couldn't replace say "Golden Retreiver" with a link to a description of the breed. Limitation of the system? Or something easily fixed? |
#56
|
|||
|
|||
If you don't like the way it is parsing things then come up with a better regular expression to cover what you are looking for. I'm happy with the way this one has performed for me. Here it is running on my Glossary of Botanical Terms which is integrated with my WIKI. I personally feel there are already enough links being made without including the ones which appear with punctuation etc. I'd actually think of making it limit the # of links more that create more than there is like this.
If you want to check to see if it's at the end of a sentence or followed by a comma simply define it in the regex: Code:
$findtext[] = "/\s".$link['text']."\s/i"; Instead of blocking the replacement of what are already URL's which is the reason I introduced the search for " word " instead of "word" in the first place way back when, you could search for "Not [" and "Not ]" to prevent the url bbcode from being broken. I'm a big fan of people learning how to do things, so somebody learn and figure it out. I can get mine to cover 2 word phrases, not sure why yours will not. I am using the same regex I posted here... Here I am replacing the phrase "Giant Vegetables", when I put it in via the admin CP i don't include the quotation marks. http://www.giantvegenetics.com/gv/sh...9&page=3&pp=10 Code:
$findtext[] = "/\s".$link['text']."\s/i"; $replacetext[] = " " . $link['text'] . " "; |
#57
|
||||
|
||||
Here is another fix to the fix of the fix (just kidding).
Yet another thought before I'll move on to the fixed code posting - make sure that the version of the php your server is runing has PCRE enabled; navigate to your admin control panel, go to 'Import & Maintenance' section; click on 'View PHP Info' link. Once you are able to view PHP info in the main panel please search for 'pcre': PCRE (Perl Compatible Regular Expressions) Support enabled If the line is missing the code may not work for you. What's fixed: - now it works with phrases - works with both words and phrases at the beggining or the end of the post Enjoy it: Code:
static $customReplaceInit = false; static $findtext = array(); static $replacetext = array(); if (!$customReplaceInit) { $textlinks = $DB_site->query(" SELECT text, link FROM " . TABLE_PREFIX . "textlink"); while($link = $DB_site->fetch_array($textlinks)) { $findtext[] = "/(\s+|^)".$link['text']."(\s+|$)/i"; $replacetext[] = " " . $link['text'] . " "; } $customReplaceInit = true; } $bbcode=preg_replace($findtext, $replacetext, $bbcode); |
#58
|
|||
|
|||
Hey everyone, i'm back for good now and i'll be able to start updating and supporting my hacks. I just read the thread and i have to thank everyone who has contributed there time to trying to make this hack work while i was away. I am going over the code now and will have an update very shortly with all fixes. Thanks again!
|
#59
|
|||
|
|||
Nice to see you back (for good???).
|
#60
|
|||
|
|||
It works!
Thanks! |
#61
|
|||
|
|||
everything works great, but I do get an error every time I add a new text link in the redirect window:
Cannot find phrase: "saved_text_link_x_successfully' |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|