vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Callback Function and $GLOBAL variable (https://vborg.vbsupport.ru/showthread.php?t=170542)

Farcaster 02-15-2008 09:02 AM

Callback Function and $GLOBAL variable
 
I am writing a modification that adds a custom bbcode tag.

So, I have this that is being eval'd on the bbcode_create hook:

PHP Code:

if (!function_exists('handle_bbcode_roll'))
{

    function 
handle_bbcode_roll(&$parser$text$option)
    {

        
// MOVED FROM IF (class_exists...
        
$GLOBALS['dicehistory'] .= "$text";
        
        if (
class_exists('vB_BbCodeParser_Wysiwyg') AND is_a($parser'vB_BbCodeParser_Wysiwyg'))
        {
            return 
$text;
        } else {
            
            
            return 
"<div><span class=\"die_description\">* $text *</span></div>";        
        }          
    }
}

$this->tag_list['option']['roll'] = array(
        
'callback' => 'handle_external',
        
'strip_empty' => false,
        
'stop_parse' => true,
        
'disable_smilies' => true,
        
'disable_wordwrap' => true,
        
'strip_space_after' => 1,
        
'external_callback' => 'handle_bbcode_roll'
    
); 

Later in the postdata_presave, I am trying to access this $GLOBALS['dicehistory'], and I am getting nothing at all. It seems that I cannot access the global array from within the callback function. Can anyone tell me why this is and how I can pass something back to be accessed during postdata_presave? (Forget that this particular example is pretty meaningless.. I do have a reason for wanting to do this)

Marco van Herwaarden 02-15-2008 09:08 AM

Okay let's take this step by step.

First are you sure that this part of the code is executed, or does it only execute the first part of the if (ie. have a valid 'vB_BbCodeParser_Wysiwyg')

Farcaster 02-15-2008 03:55 PM

It was parsing the tag as I expected, but just to test, I moved the $GLOBALS['dicehistory'] outside of the IF statement (modified PHP above to reflect). It had no effect. The variable is still empty when I try to access it either in the postdata_presave or even bbcode_parse_complete.

And thank you for trying to help! I appreciate it.


All times are GMT. The time now is 08:20 PM.

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.01477 seconds
  • Memory Usage 1,720KB
  • 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_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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