vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   adding new bbcode (https://vborg.vbsupport.ru/showthread.php?t=100995)

sabret00the 11-17-2005 10:53 AM

adding new bbcode
 
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:

Code:

[test]Testvar[/test]

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

PHP Code:

// [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
PHP Code:

/**
    * 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($message1);

        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

merk 12-19-2005 08:15 AM

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

PHP Code:

$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:

PHP Code:

<?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 [roll][/roll] 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.


All times are GMT. The time now is 04:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01168 seconds
  • Memory Usage 1,768KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (4)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (14)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete