PDA

View Full Version : Modify Post as Displayed


weinstoc
01-06-2009, 11:12 PM
We'd like to create a plugin(?) that modifies a post before it is displayed to remove URL links for a specific set of URL's as the post is being displayed:

For instance we'd like to modify http://unpaid_advertisement_site.com so that the link is removed (i.e., "http://unpaid_advertisement_site.com" instead).

I'm not sure how to accomplish this cleanly. Any advice would be appreciated.

Chuck

Lynne
01-06-2009, 11:40 PM
Have you tried the Replacement Manager? I'm not sure if it would work, but it may. Find what the link looks like in the page source - <a href="xxxx">xxxx</a> maybe? And put the full thing in to be replaced and the single non-parse link as the replacement. Again, I'm not sure if that will work.

weinstoc
01-06-2009, 11:57 PM
Have you tried the Replacement Manager? I'm not sure if it would work, but it may. Find what the link looks like in the page source - <a href="xxxx">xxxx</a> maybe? And put the full thing in to be replaced and the single non-parse link as the replacement. Again, I'm not sure if that will work.

The problem is that the replacement manager doesn't allow for enough characters. I know we can modify it but then we have to keep modifying everytime there is a new release.

Chuck

Lynne
01-07-2009, 02:32 AM
Are you talking about the size of the input box on the screen? It will just scroll with the contents of what you put in there.

Bellardia
01-07-2009, 03:55 AM
If you want to rewrite links, you'll want to use two plugins.

This one will take the text to be posted, and submit it to a function so can it can be run through a preg_replace or similar function.
<plugin active="1" executionorder="5">

<title>Title Of Mod</title>

<hookname>postbit_display_complete</hookname>

<phpcode><![CDATA[global $vbulletin;

$this->post['message'] = Function_Name($this->post['message']);

]]></phpcode>

</plugin>


Another code in the global_start hook can be used to hold the source of the link replacement, modify the post and return it however you want.

<title>Plugin Title</title>
<hookname>global_start</hookname>
<phpcode><![CDATA[
function Function_Name($post) {
global $vbulletin;
//Preg_replace + other Functions
return $post;
}
]]></phpcode>

goetz
01-07-2009, 06:45 PM
Is it possible to do a search and replace on the bb instead? Different hook location?

--------------- Added 1231361257 at 1231361257 ---------------

Are you talking about the size of the input box on the screen? It will just scroll with the contents of what you put in there.

After saving, it appears that the content is truncated to 100 characters.

Bellardia
01-07-2009, 07:20 PM
Is it possible to do a search and replace on the bb instead? Different hook location?

--------------- Added 1231361257 at 1231361257 ---------------



After saving, it appears that the content is truncated to 100 characters.

Although you can do the replace on the bb code, I believe you will have to hardcode it into the php files themselves, as standard bb codes aren't editable.

Dismounted
01-08-2009, 02:14 AM
You can modify the function of the BB code, by adding a plugin. Look at the end of class_bbcode.php.