vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Automatically change certain words (text) into links? (https://vborg.vbsupport.ru/showthread.php?t=219968)

nikki712 08-01-2009 03:58 PM

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!

Lynne 08-01-2009 04:17 PM

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']); 


nikki712 08-01-2009 04:30 PM

What do I put in the place of "message" in that plugin? Thanks!

Lynne 08-01-2009 04:49 PM

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.

nikki712 08-01-2009 04:56 PM

Got it! Thanks so much!

matthewhotdude 08-04-2009 05:05 PM

Where am I looking for this postbit_display_complete Because I can't find it

Lynne 08-04-2009 05:28 PM

Quote:

Originally Posted by matthewhotdude (Post 1861319)
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.

Chainspell 03-14-2010 03:23 AM

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?

Naama 08-05-2010 04:09 PM

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 :)

simoneaton 08-21-2010 05:41 PM

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


All times are GMT. The time now is 06:38 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.01109 seconds
  • Memory Usage 1,738KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete