Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2009, 01:37 PM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default BBCode issues again... Getting another error.

Fatal error: Call to undefined function: handle_bbcode_deck() in <snip>/forums/includes/class_bbcode.php on line 1199



Well, here we go again. Errors where there shouldn't be errors. Where am I supposed to define this? When I had the error with a previous BBCode (Mana), I added the function right above the end of class_bbcode_alt.php, and it worked. But this one is giving me trouble.

Code:
$tag_list['no_option']['mana'] = array(
				'callback' => 'handle_bbcode_manacost',
				'strip_empty' => true,
				'stop_parse' => true,
			);


$tag_list['option']['deck'] = array(
				'callback' => 'handle_bbcode_deck',
				'strip_space_after' => 2,
				'strip_empty' => true,
			);
I don't see the massive difference between the two. Meanwhile, the mana tags aren't screwing with me... Is it the option? I have the function for deck defined as "function handle_bbcode_deck($body, $name)", is that enough for the option? Can someone help me out here?
Reply With Quote
  #2  
Old 01-22-2009, 02:36 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your callback should be "handle_external". You should then add another element "external_callback" which you should define your handling function. You should define your functions in bbcode_create, using a require_once() to a file with your functions.
Reply With Quote
  #3  
Old 01-22-2009, 04:12 PM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is odd. See, the thing that's bugging me is, that one of those two tags works perfectly.

Also, can you explain the "add another element" part? Don't get that...
Reply With Quote
  #4  
Old 01-23-2009, 03:06 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$foo = array(
    
'element1' => 'this is an element of this array'
); 
Reply With Quote
  #5  
Old 01-23-2009, 04:47 PM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dammit. Still getting fatal errors.

Fatal error: Call to undefined function: bbcode_deck() in <snip>/includes/class_bbcode.php on line 1426

Dammit. I can't evaluate which line it is effectively at this point... your method didn't work.

Code:
$tag_list['option']['deck'] = array(
				'callback' => 'handle_external',
				'strip_space_after' => 2,
				'strip_empty' => true,
                                'external_callback' => 'bbcode_deck'
			);
Dropped that plugin into BBCode Fetch Tags.

Code:
require_once("http://forums.mtgdarkness.com/includes/bbcode_deck.php");
Dropped that into bbcode_create.

The bbcode_deck.php file is basically this:

Code:
<?php
function bbcode_deck($body, $name)
{
(working function goes here)
}
?>
Reply With Quote
  #6  
Old 01-24-2009, 02:46 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You cannot use URLs in includes to include local PHP. It will go to the URL and look at the output from that file, which is not what you want.
PHP Code:
require_once(DIR '/includes/bbcode_deck.php'); 
Reply With Quote
  #7  
Old 01-24-2009, 08:36 AM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I see. Thanks. That fixed it.

And how about adding a little clickable icon like with other bbcodes? Is that possible?
Reply With Quote
  #8  
Old 01-24-2009, 09:18 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you can do that by editing one of the editor templates (I'm not sure, I have not had any need to do it before), editor_toolbar, maybe?
Reply With Quote
  #9  
Old 01-24-2009, 10:07 AM
MTGDarkness MTGDarkness is offline
 
Join Date: Dec 2008
Posts: 270
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, I looked at that before, but the code there is rather... specialized.

This is from editor_toolbar_on.

Code:
<if condition="$show['url_bbcode']">
					<td><div class="imagebutton" id="{$editorid}_cmd_createlink"><img src="$stylevar[imgdir_editor]/createlink.gif" width="21" height="20" alt="$vbphrase[insert_link]" /></div></td>
I'm pretty sure that it's {$editorid} that makes the javascript code work, but I'm not sure where to edit or reproduce that.

Also, another thing... For some reason, with all the above functioning correctly, it isn't defining the 'option' correctly.

Code:
<?php
function bbcode_deck($body, $name)
{
	// Start output and build header row with name.
	$output .= '<table width="75%" align="center" cellpadding="0" cellspacing="0" style="border: 1px solid #000000;">
			<tr><td class="tcat" style="padding:5px; font-size:20px;">' . $body . '</td></tr>
			<tr><td class="alt2"><table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin:5px;">';
		
(rest of function)
}
?>
The bbcode to that is: [deck=name of deck]number*content1
number*content2[/deck]

(of course, any number of content items)... For some reason, with this, $body automatically becomes "Object". I dunno why...
Reply With Quote
  #10  
Old 01-24-2009, 12:05 PM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are not structuring your function correctly. Rather than explain it, I will just post the comment from class_bbcode.php.
PHP Code:
/**
* Allows extension of the class functionality at run time by calling an
* external function. To use this, your tag must have a callback of
* 'handle_external' and define an additional 'external_callback' entry.
* Your function will receive 3 parameters:
*    A reference to this BB code parser
*    The value for the tag
*    The option for the tag
* Ensure that you accept at least the first parameter by reference!
*
* @param    string    Value for the tag
* @param    string    Option for the tag (if it has one)
*
* @return    string    HTML representation of the tag
*/ 
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:45 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04535 seconds
  • Memory Usage 2,260KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_code
  • (3)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete