vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Using $vbphrase in plugin (https://vborg.vbsupport.ru/showthread.php?t=178318)

D.Ilyin 05-06-2008 02:14 PM

Using $vbphrase in plugin
 
Can some body help me with next problem:
I need that my plugin return some value with global phrase
when i use this construction:
PHP Code:

return "$vbphrase[sp_default_header] $sp_content"

it returns only second variable.

How can i use $vbphrase['.....'] in plugins?

Farcaster 05-06-2008 09:59 PM

Yeah, you can use $vbphrase in a plugin. Are you certain that the phrase you are trying to use is in the global phrase set? If it is not, you might have to use fetch_phrase or fetch_phrase_group to get it. Also, if this is a standalone php file you have created, I believe you have to indicate the phrase groups you want before you include the global.php file.

Boofo 05-06-2008 11:40 PM

Just do a

Quote:

global $vbphrase;
at the beginning of the plugin. That should me it global if it already isn't.

--------------- Added [DATE]1210120927[/DATE] at [TIME]1210120927[/TIME] ---------------

If that doesn;lt work, you might try:

return $vbphrase[sp_default_header] ." $sp_content";

D.Ilyin 05-07-2008 08:36 AM

Quote:

Are you certain that the phrase you are trying to use is in the global phrase set?
yes. it's global. even if i use vB own global phrase...
Quote:

Also, if this is a standalone php file you have created, I believe you have to indicate the phrase groups you want before you include the global.php file.
no it's a too plugins. not a file.
First it's a function with condition.
Second it's function caller.
In condition i need to add phrase that inserted when function called whithout parametrs.
Thats it :(
Quote:

global $vbphrase;
added it in first plugin. but it is not working too :(

I was trying this:
PHP Code:

return $vbphrase[sp_default_header] .$sp_content"

returned CONTENT
PHP Code:

return "$vbphrase[sp_default_header] $sp_content"

returned CONTENT
and when i make mistake
PHP Code:

return $vbphrase-[sp_default_header] .$sp_content"

returned -[sp_default_header]CONTENT

Thanks guys! For trying to help!

PHP Code:

global $vbphrase//added by Boofo advice later
if (!function_exists('handle_sp'))
{
    function 
handle_sp(&$parser$sp_body$options)
    {
        if (
$options == null)
        {
            
$sp "
            <!--CONTENT-->
                        
$sp_body
            <!--/CONTENT-->"
;
            
$sp $vbphrase['sp_default_header'] . $sp;
        }
        else
        {
            
$sp "
            <!--CONTENT-->
                        
$sp_body
                        
$options
            <!--/CONTENT-->"
;

        }
        return 
"$sp";
    }


--------------- Added [DATE]1210153052[/DATE] at [TIME]1210153052[/TIME] ---------------
BTW my vB version 3.7.0
Have some body advices?

Marco van Herwaarden 05-07-2008 09:06 AM

PHP Code:

global $vbphrase

This should be (first line seems best) inside your function.
so:
PHP Code:

if (!function_exists('handle_sp')) 

    function 
handle_sp(&$parser$sp_body$options
    { 
        global 
$vbphrase//added by Boofo advice later 
        
if ($options == null
............. 

For more information see the PHP manual on Variable Scope.

Boofo 05-07-2008 09:25 AM

Ah, I didn't know he was doing a function.

Marco van Herwaarden 05-07-2008 09:55 AM

Quote:

Originally Posted by Boofo (Post 1511442)
Ah, I didn't know he was doing a function.

If it was not inside a function, then he would not have a scope problem. ;)

Boofo 05-07-2008 10:37 AM

I've never heard of a scope problem before. At least, not called that, anyway. Thanks for pointing it out. I will have to read up on it.

D.Ilyin 05-07-2008 10:42 AM

Marco van Herwaarden thanks! :) All works for now!
shame for me, but i fogot about variables scopes :(
Boofo sory that i didn't tell it in my first post. And thank for your help too!


All times are GMT. The time now is 06:35 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.04270 seconds
  • Memory Usage 1,748KB
  • 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
  • (7)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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