PDA

View Full Version : Mini Mods - Replace Word in Pagetext


Andy
02-12-2010, 10:00 PM
This plugin is designed to replace words in the pagetext. For example to always make sure there is a www in your forums url.

Search: http://vbulletin.org
Replace: http://www.vbulletin.org

You will need to create two plugins.


Product: vbulletin
Hook Location: postdata_presave
Title: Replace Word postdata
Execution Order: 5
Plugin PHP Code:

$search = array(
'http://vbulletin.com',
'http://vbulletin.org',
);
$replace = array(
'http://www.vbulletin.com',
'http://www.vbulletin.org',
);
$this->post['pagetext'] = str_replace($search, $replace, $this->post['pagetext']);



Product: vbulletin
Hook Location: threaddata_presave
Title: Replace Word Threaddata
Execution Order: 5
Plugin PHP Code:

$search = array(
'http://vbulletin.com',
'http://vbulletin.org',
);
$replace = array(
'http://www.vbulletin.com',
'http://www.vbulletin.org',
);
$this->post['pagetext'] = str_replace($search, $replace, $this->post['pagetext']);

BSMedia
02-13-2010, 07:02 PM
why not use replacement manager built in?

Andy
02-13-2010, 07:23 PM
why not use replacement manager built in?

Replacement manager doesn't actually change the pagetext, it simply replaces the html that is outputted. This can be a problem when a member is searching for a particular word. Therefore it's better to correct the word in the database. I don't recommend using the Replacement Manager.

MarkJW
02-13-2010, 10:05 PM
So this is a wordfilter type thing? Awesome, I can screw with my members by making words change! :3

wolfyman
02-20-2010, 03:49 PM
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:


$search = array(
'this1',
'this2',
);
$replace = array(
'that1',
'that 2',
);
$this->post['pagetext'] = str_replace($search, $replace, $this->post['pagetext']);

black hours
03-16-2010, 09:43 PM
I want this plugin Turns to product Contain a control panel to be the best

Shogo
04-27-2010, 12:38 PM
Wat is the hook location for the same effect in the title of the threads?

Thx

Best regards

alhindasi
08-14-2010, 08:42 PM
can you do it in "product" to be easy to control it