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 08-01-2009, 03:58 PM
nikki712 nikki712 is offline
 
Join Date: Sep 2006
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Automatically change certain words (text) into links?

Is there a way to automatically change certain words in posts into links? For example, if someone types the word California on my forum, is there a way to make that word turn into a link to my California page on my site? I looked for a hack for this, but couldn't find one. Maybe I'm overlooking it. Any help would be appreciated. Thanks!
Reply With Quote
  #2  
Old 08-01-2009, 04:17 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There are Replacement Variables, but those are site wide, not just for posts. You can write a simple plugin to do a search/replace for words in posts:
location: postbit_display_complete
PHP Code:
$word = array(
'word1',
'word2'
);

$link = array(
'<a href="/forums/link1.php">Word1</a>',
'<a href="/forums/link2.php">Word2</a>'
);

$this->post['message'] = str_ireplace($word$link$this->post['message']); 
Reply With Quote
  #3  
Old 08-01-2009, 04:30 PM
nikki712 nikki712 is offline
 
Join Date: Sep 2006
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What do I put in the place of "message" in that plugin? Thanks!
Reply With Quote
  #4  
Old 08-01-2009, 04:49 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The only things you would change are the $word and $link arrays. Leave the last line alone.

That plugin changes the words when the message is parsed. If you need to change it when the message is created, you'd have to use a different hook location and the code would change. I haven't done that before, so I don't have a quick plugin to post for that.
Reply With Quote
  #5  
Old 08-01-2009, 04:56 PM
nikki712 nikki712 is offline
 
Join Date: Sep 2006
Posts: 105
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Got it! Thanks so much!
Reply With Quote
  #6  
Old 08-04-2009, 05:05 PM
matthewhotdude matthewhotdude is offline
 
Join Date: Jul 2009
Posts: 560
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where am I looking for this postbit_display_complete Because I can't find it
Reply With Quote
  #7  
Old 08-04-2009, 05:28 PM
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 matthewhotdude View Post
Where am I looking for this postbit_display_complete Because I can't find it
It's a hook_location. You find it when you create a plugin.
Reply With Quote
  #8  
Old 03-14-2010, 03:23 AM
Chainspell Chainspell is offline
 
Join Date: Jan 2010
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

not working for me im on vb4.0

--------------- Added [DATE]1268554434[/DATE] at [TIME]1268554434[/TIME] ---------------

it works wonderfully on the forums. any reason why it doesnt work in the blogs section?
Reply With Quote
  #9  
Old 08-05-2010, 04:09 PM
Naama Naama is offline
 
Join Date: May 2009
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi and thank you for this code, it works great!

But there is any chance that I can make it convert ONLY one word (in case that the word repeat herself) in the text to link?

Thanks
Reply With Quote
  #10  
Old 08-21-2010, 05:41 PM
simoneaton simoneaton is offline
 
Join Date: Jun 2010
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Tried this and it is now working for me as I get this error message;

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36

Parse error: syntax error, unexpected '=' in /home/sportsbo/public_html/includes/class_postbit.php(314) : eval()'d code on line 36
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 10:45 PM.


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.04211 seconds
  • Memory Usage 2,252KB
  • Queries Executed 11 (?)
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
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete