Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 09-12-2009, 08:47 AM
remotay remotay is offline
 
Join Date: Sep 2007
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Is This Possible? Change Keywords Into Links automatically [Variable Tool won't work]

I've tried searching the forums with no luck. I want it so on every forum post, if someone says the word, lets say Meepo, it will link to meepo.com

The variable replace manager is a good tool, but it replaces EVERYTHING. I just need this done in the posts area.

If this isn't built into Vbulletin I would gladly pay someone to set it up for me. I would enter all the keywords and links manually.
Reply With Quote
  #2  
Old 09-12-2009, 02:40 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've posted this quite a few times and there is a version of it in the modifications area:

hook location - postbit_display_complete

PHP Code:
$word = array(
'word 1',
'word 2',
);

$link = array(
'<a href="link1.php">Link 1</a>',
'<a href="link2.php">Link 2</a>',
);

$this->post['message'] = str_replace($word$link$this->post['message']); 
(I use str_ireplace, but that's your choice - google the differences.)
Reply With Quote
  #3  
Old 09-13-2009, 01:16 AM
remotay remotay is offline
 
Join Date: Sep 2007
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne, thanks so much for the quick reply. To be fair I did a considerable amount of searching before posting this. I guess I was searching the wrong keywords.

Your code works perfectly and I figured out how to implement it, but one small issue. How can I make it so it's not case sensitive?

Ex: Whether users type out Meepo, meepo or mEEpo it should still link to the same location? Using the code above it needs to be case sensitive for it to link correctly.
Reply With Quote
  #4  
Old 09-13-2009, 02:49 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by remotay View Post
Lynne, thanks so much for the quick reply. To be fair I did a considerable amount of searching before posting this. I guess I was searching the wrong keywords.

Your code works perfectly and I figured out how to implement it, but one small issue. How can I make it so it's not case sensitive?

Ex: Whether users type out Meepo, meepo or mEEpo it should still link to the same location? Using the code above it needs to be case sensitive for it to link correctly.
That is why I suggested googling str_ireplace and perhaps using it instead.
Reply With Quote
  #5  
Old 09-13-2009, 10:59 AM
remotay remotay is offline
 
Join Date: Sep 2007
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Lynne, you've been extremely helpful, but I have ONE last question, I promise . I'll certainly return the favor to someone else on the forums who needs help one day.

Works like a charm, but I tried to make it so it only replaces each occurrence of the keyword ONCE rather than every single time it's mentioned in the post.

Some googling led me to find this piece of code 'function str_replace_once' but I need it as istr_replace_once which apparently doesn't exist :[. Even if it did work though I'm not sure if it would work the way I need it to work?

I have 100 keywords that are set to be replaced with that keyword as a URL - So if a post mentions 5 of those keywords, they should all be converted, but if the same posts mentions the same keyword twice, only one should be converted?

Also, Lynne I would certainly donate something like $5 for your time :P, especially now that this got a tad bit more complicated.
Reply With Quote
  #6  
Old 09-13-2009, 02:40 PM
AfterWorldForum AfterWorldForum is offline
 
Join Date: Dec 2008
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by remotay View Post
...
Some googling led me to find this piece of code 'function str_replace_once' but I need it as istr_replace_once which apparently doesn't exist :[. Even if it did work though I'm not sure if it would work the way I need it to work?

...

Also, Lynne I would certainly donate something like $5 for your time :P, especially now that this got a tad bit more complicated.
Try putting MEEPO in your $word array, and within the str_replace_once, wrap a strtoupper function around the $word parameter.

This way, regardless of case in the post, it will always evaluate to the fully capitalized word stored in your array.

HTH.

Peter
Reply With Quote
  #7  
Old 09-13-2009, 02:55 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^ What he said is a very good solution and something I would not have thought of, so thank you EntropiaPlanets for posting that!
Reply With Quote
  #8  
Old 09-13-2009, 09:18 PM
remotay remotay is offline
 
Join Date: Sep 2007
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Will ucwords() work as well? If I use ucwords() will I need to make all of the words in the array lower case for this one to work?

Because first character of each word uppercase looks cleaner than all caps
Reply With Quote
  #9  
Old 09-14-2009, 03:51 PM
AfterWorldForum AfterWorldForum is offline
 
Join Date: Dec 2008
Posts: 154
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by remotay View Post
Will ucwords() work as well? If I use ucwords() will I need to make all of the words in the array lower case for this one to work?

Because first character of each word uppercase looks cleaner than all caps
The only place it will be "seen" is in the code, and even there, no real person is looking at it (well, you and perhaps some other coders).

What goes on in the kitchen might not be pretty to look at, but as long as the clientele never finds out, they don't care


And Lynne, your most welcome
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:10 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04133 seconds
  • Memory Usage 2,252KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete