View Full Version : adding new bbcode
sabret00the
11-17-2005, 10:53 AM
could someone tell me how to do it.
i should just be able to add the new function, add to the tag_list, throw in a new template and voila. however i'm not sure where the hook is for the functions (and i'm hoping that's what's causing me all the errors i'm getting because i am getting a few).
sabret00the
11-19-2005, 08:24 AM
*bump*
vtx1800
11-19-2005, 09:14 AM
What are you trying to add? I did a few, seemed to be easy.
Marco van Herwaarden
11-19-2005, 10:47 AM
Hehe, i also don't have a clue what he is asking. :d
sabret00the
11-19-2005, 11:01 AM
i want to add a bbcode via the class because of the fact it requires back-end processing, however in the old version.
i'd simply find each instance of the quote being created and add my relative code underneath that, however with the new plugin system that's not quite possible.
so i'm wondering how i'd add bbcode.
i've added the taglist stuff, now i've just gotta add the function but not sure what hook to use for that.
vtx1800
11-19-2005, 11:20 AM
In the custom BB code area, you can set the BBcode var, and the html to use for that var. you use {param} as the var in the html. Example:
Testvar
In the ACP, your html would be <a href='http://www.domain.com/user/{param}'>My Profile</a>
Then when the code is used, it will return <a href='http://www.domain.com/user/Testvar'>My Profile</a>
sabret00the
11-19-2005, 11:45 AM
the version require php processing
// [SPOILER]
$tag_list['no_option']['spoiler'] = array(
'callback' => 'handle_bbcode_spoiler',
'strip_empty' => true,
'strip_space_after' => 1
);
// [SPOILER=XXX]
$tag_list['option']['spoiler'] = array(
'callback' => 'handle_bbcode_spoiler',
'strip_empty' => true,
'strip_space_after' => 1,
'parse_option' => true
);this one uses the bbcode_fetch_tags plugin
but i still need to find the hook for the function
/**
* Handles a [spoiler] tag. Displays a string in an area indicating it was a spoiler.
*
* @param string The body of the quote.
* @param string If tag has option, then a reason is present.
*
* @return string HTML representation of the tag.
*/
function handle_bbcode_spoiler($message, $reason = '')
{
global $vbulletin, $vbphrase, $stylevar, $show;
// remove smilies from username
$reason = $this->strip_smilies($reason);
$show['reason'] = ($username != '') ? TRUE : FALSE);
$message = $this->strip_front_back_whitespace($message, 1);
if ($this->options['cachable'] == false)
{
$show['iewidthfix'] = (is_browser('ie') AND !(is_browser('ie', 6)));
}
else
{
// this post may be cached, so we can't allow this "fix" to be included in that cache
$show['iewidthfix'] = false;
}
$template = 'bbcode_spoiler';
eval('$html = "' . fetch_template($template) . '";');
return $html;
}
El_Muerte
12-19-2005, 07:33 AM
*bump*
anyone have a solution for this yet?
I also need to add a bbcode tag that has a callback
the problem is that the vbcode parser calls $this->$callback(...)
I don't want to edit the original file for this hack
You can define it as a user function (which youll need to call using a calling function) in the _start hook for the class. (i think)
El_Muerte
12-19-2005, 10:18 AM
Ah figured it out
$tag_list['no_option']['mytag'] = array(
'callback' => 'handle_external',
'external_callback' => 'handle_bbcode_mytag',
'strip_empty' => true,
);
function handle_bbcode_mytag($parser, $param, $option)
{
}
tuxz0r
02-21-2006, 09:34 PM
Ok, I think I get as much so far on this topic, but for some reason none of my added codes are being parsed. I'm using the bbcode_create hook for a bbcode plugin, here's my xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" product="dice_roll">
<title>parse vBCode roll</title>
<hookname>bbcode_create</hookname>
<phpcode><![CDATA[$this->tag_list['no_option']['roll'] = array(
'callback' => 'handle_external',
'strip_empty' => true,
#'stop_parse' => false,
#'disable_smilies' => true,
#'disable_wordwrap' => true,
#'strip_space_after' => 1
'external_callback' => 'handle_rolltag'
);
$this->tag_list['option']['roll'] = array(
'callback' => 'handle_external',
'strip_empty' => true,
#'stop_parse' => false,
#'disable_smilies' => true,
#'disable_wordwrap' => true,
#'strip_space_after' => 1
'external_callback' => 'handle_rolltag'
);
if (!function_exists('handle_rolltag')) {
require_once(DIR.'/includes/class_dice.php');
function handle_rolltag(&$parser, $code, $option='') {
$dice = new Dice;
$code = preg_replace('!\[roll\](.*)\[/roll\]!e',
'\'<i>(\\1)</i> <b>\'.\$dice->roll(\'\\1\').\'</b>\'',
$code
);
return $code;
}
}
#if($this->is_wysiwyg()) {
#$this->unparsed_tags[] = 'roll';
#}]]></phpcode>
</plugin>
</plugins>
What exactly am I missing here? I've also added the bbcode to the bbcode table, so you see a showing up in custom bbcode manager. I'm a bit confused.
tuxz0r
06-29-2006, 05:07 PM
*bump*
Maybe someone has link to a thread or other resource on how to add a custom BB Code which needs PHP processing on the backend?
Adult SEO
11-14-2006, 01:32 PM
Hi!
I am also interested in more information!
Best Regards,
Jan Jaap
sabret00the
12-11-2006, 10:17 AM
for the life of me i couldn't figure out where to define the function so i ended up hardcoding it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.