PDA

View Full Version : Modify Article Text via a Plugin


dartho
03-02-2011, 04:00 AM
I've been trying to find how to do this, but have had no luck.

I want to change BBCode behaviour on the fly in articles. With posts I can do this by changing $text and reparsing into $parsedtext but can not find what to change for article content...

If anyone in the know would care to help, it'd be much appreciated...
Thanks

dartho
03-04-2011, 09:18 AM
An alternative would be to find a way to have vBulletin not use the BBCode parsed articles as all I really want to do is change the way user defined BBCodes behave under certain ciurcumstances (such as paticular styles)

Any suggestions? Thanks

Lynne
03-04-2011, 04:08 PM
Can you post the code that you tried but isn't working? Please make sure to post the hook locations and put the code in code tags.

dartho
03-04-2011, 08:36 PM
I don;t have any not working code. I just do not know what var the cms article text is stored in to manipulate it. :o I have working code for forum posts which I hoped to apply also to CMS articles

Lynne
03-04-2011, 10:07 PM
For actual articles (as compared to Static pages or PHP Direct Evaluation pages), the template name is vbcms_content_article_page . And, in that template, they are using the variable $pagetext to spit out the pagetext.

dartho
04-06-2011, 10:26 PM
Thanks for you help so far, Lynne.

What I have working for forum posts is on hook bbcode_parse_start and the code does a preg_replace on $text and then runs it through the bbcode_parser to get $parsedtext


$text=preg_replace($my_search,$my_replace,$text);

if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($GLOBALS['vbulletin'], fetch_tag_list(),false);
}
$parsedtext=$bbcode_parser->do_parse($text, true, true, true, true, true, true);
}

No luck using $pagetext for articles and I'm not sure that hook is even called? Any further suggestions which might point me in teh right direction on how to apply this to articles?

Thanks!

Lynne
04-07-2011, 03:33 AM
If you go into debug mode (look in the articles forums), then you will get a list of all the hooks used on that page and be able to pick a good hook location to use.

dartho
04-08-2011, 04:51 AM
Seems I have to use the variable $view->pagetext to get the article content - I'm getting inconsistent results, but at least I'm getting somewhere now ...

Thanks

Lynne
04-08-2011, 03:52 PM
The actual variable name/syntax will change depending on what hook location you use. That is why it is always important to actually go look at the code around where the hook is being called.