View Full Version : Custom BBCode for this?
pjkcards
01-29-2014, 09:01 AM
What would be the best way to implement this suggestion?
[removed]
The parameter needs underscores between each letter, as shown in the example. Thanks.
You could try this: create a new plugin using hook location bbcode_create and this code:
if (!function_exists('handle_bbcode_alg'))
{
function handle_bbcode_alg(&$parser, $code, $option='')
{
$param = str_replace(array(' ', '"', "'"), array('_', '', ''), $code);
return '<a href="http://alg.garron.us/?alg='.$param.'">'.$code.'</a>';
}
}
$this->tag_list['no_option']['alg'] = array(
'callback' => 'handle_external',
'strip_empty' => true,
'stop_parse' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1,
'external_callback' => 'handle_bbcode_alg'
);
if you want to add a button in the editor for that code, you can go to the bbcode manager and create a bbcode with code alg. Set "Use {option}" to No and enter your button image, but you can put in whatever you want for the html replacement and the other settings, since they won't be used.
Another way might be to installl this mod: https://vborg.vbsupport.ru/showthread.php?t=264896 (a very cool mod which I'm surprised has gotten more attention), then just use the bbcode manager to create a new bbcode, and put the php in the html replacement box, like:
<?php
$p = str_replace(array(' ', '"', "'"), array('_', '', ''), $param);
return '<a href="http://alg.garron.us/?alg='.$p.'">'.$param.'</a>';
and just to be clear, you then don't need to create any plugins or change anything else.
BTW, I haven't test this, so if you decide to try this way and it doesn't work, let us know.
pjkcards
02-02-2014, 09:35 AM
You could try this: create a new plugin using hook location bbcode_create and this code:
if (!function_exists('handle_bbcode_alg'))
{
function handle_bbcode_alg(&$parser, $code, $option='')
{
$param = str_replace(array(' ', '"', "'"), array('_', '', ''), $code);
return '<a href="http://alg.garron.us/?alg='.$param.'">'.$code.'</a>';
}
}
$this->tag_list['no_option']['alg'] = array(
'callback' => 'handle_external',
'strip_empty' => true,
'stop_parse' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1,
'external_callback' => 'handle_bbcode_alg'
);
if you want to add a button in the editor for that code, you can go to the bbcode manager and create a bbcode with code alg. Set "Use {option}" to No and enter your button image, but you can put in whatever you want for the html replacement and the other settings, since they won't be used.
I tried this, but it removed the ' from R' so the URL just had R. The R' has to be R- in the link, as shown in the example in the link I posted.
Another way might be to installl this mod: https://vborg.vbsupport.ru/showthread.php?t=264896 (a very cool mod which I'm surprised has gotten more attention), then just use the bbcode manager to create a new bbcode, and put the php in the html replacement box, like:
<?php
$p = str_replace(array(' ', '"', "'"), array('_', '', ''), $param);
return '<a href="http://alg.garron.us/?alg='.$p.'">'.$param.'</a>';
and just to be clear, you then don't need to create any plugins or change anything else.
BTW, I haven't test this, so if you decide to try this way and it doesn't work, let us know.
Once I did this, and used the tag, nothing shows up in the post. It just shows up as blank. Additionally, se the comment above about R' needing to show as R- in the link (see example in link).
Thanks guys. Further help would be much appreciated.
Yeah, I got thinking about removing quotes and forgot that a single quote was part of the "code". So anyway, try this:
if (!function_exists('handle_bbcode_alg'))
{
function handle_bbcode_alg(&$parser, $code, $option='')
{
$param = str_replace(array(' ', "'"), array('_', '-'), $code);
return '<a href="http://alg.garron.us/?alg='.$param.'">'.$code.'</a>';
}
}
$this->tag_list['no_option']['alg'] = array(
'callback' => 'handle_external',
'strip_empty' => true,
'stop_parse' => true,
'disable_smilies' => true,
'disable_wordwrap' => true,
'strip_space_after' => 1,
'external_callback' => 'handle_bbcode_alg'
);
pjkcards
02-04-2014, 08:55 AM
That worked, many thanks.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.