Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2010, 12:14 AM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default specific word replacement

I know how to replace a list of words with *.... but what if I want to replace words on a word-by-word basis?

"Cat " to "Dog"
"Bear" to "Pig"
"XXX" to "YYY"

etc?

Is that possible?
Reply With Quote
  #2  
Old 02-13-2010, 03:44 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure, just use a plugin to do a str_replace. I think I've written the code for this quite a few times - here's a copy from another thread:
PHP Code:
$word = array(
'word 1',
'word 2',
);
$link = array(
'xxxx',
'yyyy',
);
$this->post['message'] = str_replace($word$link$this->post['message']); 
It should work in vB4, I think.
Reply With Quote
  #3  
Old 02-13-2010, 11:02 AM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Sure, just use a plugin to do a str_replace. I think I've written the code for this quite a few times - here's a copy from another thread:
PHP Code:
$word = array(
'word 1',
'word 2',
);
$link = array(
'xxxx',
'yyyy',
);
$this->post['message'] = str_replace($word$link$this->post['message']); 
It should work in vB4, I think.
So to make a plugin I go to

Plugins & Products > Add new Plugin

Then I need:

Product type: ?
Hook Location: ?
Title: Custom Word Replacement
Execution Order: ?

Plugin PHP Code

PHP Code:
$word = array(
'word 1',
'word 2',
);
$link = array(
'Replacement 1',
'Replacement 2',
);
$this->post['message'] = str_replace($word$link$this->post['message']); 
--------------- Added [DATE]1266066243[/DATE] at [TIME]1266066243[/TIME] ---------------

or did I get the replacement values wrong? I don't understand what $link and $word do.
Reply With Quote
  #4  
Old 02-13-2010, 04:06 PM
Andy Andy is offline
 
Join Date: Sep 2003
Location: San Francisco
Posts: 138
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here are instructions on how to create a plugin to Replace Words in the pagetext.

https://vborg.vbsupport.ru/showthread.php?t=235769
Reply With Quote
  #5  
Old 02-19-2010, 01:24 PM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andy View Post
Here are instructions on how to create a plugin to Replace Words in the pagetext.

https://vborg.vbsupport.ru/showthread.php?t=235769
perfect, thanks
Reply With Quote
  #6  
Old 02-22-2010, 01:49 PM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by wolfyman View Post
alert!

I installed this and thought it was working great.. but for some reason, the Replace Word postdata plugin causes a weird error.

With this enabled, when you move a thread from one forum to another.... the first post gets stripped of data.

wtf is that all about?!

Here is my php code:

PHP Code:
$search = array(
'this1',
'this2',
);
$replace = array(
'that1',
'that 2',
);
$this->post['pagetext'] = str_replace($search$replace$this->post['pagetext']); 
Any ideas out there?
Reply With Quote
  #7  
Old 02-22-2010, 10:01 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've never had any problems with mine. The difference between ours is what we apply it to (pagetext versus message), so perhaps that has something to do with it.
Reply With Quote
  #8  
Old 02-23-2010, 12:38 AM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

how do you do that?

I need it in terms a 6 year old can understand
Reply With Quote
  #9  
Old 02-23-2010, 01:04 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What do you mean? I'm talking about the difference in our plugins. I posted what I use in post 2 and I do a replace for $this->post['message'] whereas you do a replace for $this->post['pagetext']
Reply With Quote
  #10  
Old 02-23-2010, 01:15 PM
wolfyman's Avatar
wolfyman wolfyman is offline
 
Join Date: Apr 2005
Posts: 719
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

so the code stays the same, I just replace 'pagetext' with 'message'?
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:31 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.04246 seconds
  • Memory Usage 2,271KB
  • 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
  • (4)bbcode_php
  • (3)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