The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help with plugin to strip table tags
Looking to strip table tags from posts on a particular style. I haven't put the if statement in yet for the styleid as the main code doesn't work.
Here is what I've been trying, with variations, but it never seems to work (created the phrase below): Code:
hook location: postbit_display_start $this->post['pagetext_html'] = preg_replace('/\[TABLE=.*?\](.*?)\[\/TABLE\]/si', construct_phrase($vbphrase['hidetable_message'], $session['sessionurl_q']), $this->post['pagetext_html']) |
#2
|
|||
|
|||
Well, post['pagetext_html'] probably contains html instead of bbcode. Maybe what you want to do is use hook bbcode_create to change $this->tag_list, and change the function that gets called to parse the table tag (check the current styleid if you only want it to change for one style).
|
#3
|
|||
|
|||
Quote:
Code:
$this->post['pagetext_html'] = preg_replace('/\[img\](.*)\[\/img\]/im', construct_phrase($vbphrase['hideimg_message'], $session['sessionurl_q']), $this->post['pagetext_html']); |
#4
|
|||
|
|||
The posts are parsed from bbcode into html, and then the result is saved in the postparsed table so that it doesn't have to be done every time (it may be a feature that can be turned off, I'm not sure offhand). And the pagetext_html field is the parsed version. But I think for some reason IMG tags aren't preparsed, which is probably why the code you copied works for img tags.
I'm not sure offhand what [TABLE]...[/TABLE] ends up as in html. If there's any way to do your replacement with html tags, maybe you can do that. Otherwise, what I was talking about above would be done something like this: hook location bbcode_create: Code:
$this->tag_list['option']['table']['callback'] = 'handle_external'; $this->tag_list['option']['table']['external_callback'] = 'my_handle_table'; $this->tag_list['no_option']['table']['callback'] = 'handle_external'; $this->tag_list['no_option']['table']['external_callback'] = 'my_handle_table'; if (!function_exists('my_handle_table')) { function my_handle_table($parser, $data, $option) { global $styleid; if ($styleid != X) return $parser->parseTableTag($data, $option); global $vbphrase, $session; return construct_phrase($vbphrase['hideimg_message'], $session['sessionurl_q']); } } I haven't tested the above at all, so I'm not certain about it. One thing is that this will do the replacement even for 'alt' bbcode parsers, like if it's being parsed to plain text for a preview or something. You may or may not want that, I don't know. Sorry if this isn't broken down enough - feel free to ask more questions if it doesn't work like you want. |
#5
|
|||
|
|||
Thanks, haven't had time to play with this but will give it a go later.
|
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|