vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Calling PHP in BBCode (https://vborg.vbsupport.ru/showthread.php?t=212048)

Gargi 07-15-2009 09:39 AM

php basics, I see :D

Thanks for that hint! Also works with the if / else and so on.

PHP Code:

$tag_list['option']['count'] = array(  
    
'callback' => 'handle_external'
    
'external_callback' => 'handle_bbcode_count_callback',  
    
'strip_empty' => true  
);  
   
if(!
function_exists('handle_bbcode_count_callback'))  
{  
    function 
handle_bbcode_count_callback(&$parsed$value$option)  
    {  
                if ( 
$option )
                  {
                  
$result $option;         
                  return 
"Hello this is ".$value.",<br />my number is ".$result;
                  }
                  else 
                 {
                  
$result $option;         
                  return 
"Hello this is ".$value.",<br />my number is ".$result;
                  }
     }  




Now I just have to find out how to use otpion and no_option in order to get two different outputs.

cu
Gargi

Dismounted 07-15-2009 09:47 AM

Quote:

Originally Posted by Gargi (Post 1849129)
Now I just have to find out how to use otpion and no_option in order to get two different outputs.

Just use two different functions.

Gargi 07-15-2009 10:14 AM

Jeppa. That did the trick:

PHP Code:

$tag_list['option']['trace'] = array(  
    
'callback' => 'handle_external'
    
'external_callback' => 'handle_bbcode_trace_callback',  
    
'strip_empty' => true  
);

$tag_list['no_option']['trace'] = array(  
    
'callback' => 'handle_external'
    
'external_callback' => 'handle_bbcode_trace_callback2',  
    
'strip_empty' => true  
);  
   
if(!
function_exists('handle_bbcode_trace_callback'))  
{  
    function 
handle_bbcode_trace_callback(&$parsed$value$option)  
    {  
     if ( 
$option )
     {
     
$result $option;         
     return 
"Hello this is ".$value.",<br />my number is ".$result;
     }
     else 
     {
     
$result $option;         
     return 
"Hello this is ".$value.",<br />my number is ".$result;
     }
    }  
}

if(!
function_exists('handle_bbcode_trace_callback2'))  
{  
    function 
handle_bbcode_trace_callback2(&$parsed$value$option)  
    {  
    return 
"Hello this is ".$value."!"
    }  


From here all gates are open now ;) Thanks for your help!

cu
Gargi

Gargi 07-16-2009 09:13 PM

Nice thing is, that this way I'm able to use multiple options devided maybe by a ";" .

[tag="opt1;opt2"]value[/tag]

PHP Code:

$tag_list['option']['XYZ'] = array(   
    
'callback' => 'handle_external',  
    
'external_callback' => 'handle_bbcode_XYZ_callback',   
    
'strip_empty' => true   
);   
if(!
function_exists('handle_bbcode_XYZ_callback'))   
{  
    function 
handle_bbcode_XYZ_callback(&$parsed$value$option)   
    {   
      
     
$split explode(";"$option);
     return 
$split[0]."<br />".$split[1];
     }


Very handy if you need some more variables for a function.

cu
Gargi

1Unreal 07-17-2009 01:01 AM

Someone should write a tutorial on this, it was really hard to work out how to do it the first time.

Gargi 07-19-2009 05:12 PM

Quote:

Originally Posted by 1Unreal (Post 1850291)
Someone should write a tutorial on this, it was really hard to work out how to do it the first time.

Since english is not my mothertongue it will be hard work to write an english tutorial. But I'll trie it and will post it here. But give me some extra time to do it :)

cu
Gargi

Jhonnyf 08-04-2009 10:09 AM

Work fine, but, How about Switch Standard and Avanced editor? o Preview Message.. this is Parsed but not restore to BBCODE original form

ragtek 08-04-2009 11:51 AM

I think you would also need a plugin at bbcode_create hook
PHP Code:

if ($this->is_wysiwyg())
{
    
$this->unparsed_tags[] = 'xyz';


xyz = your tag;)


All times are GMT. The time now is 08:09 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.01544 seconds
  • Memory Usage 1,761KB
  • 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
  • (4)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete