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 05-06-2008, 02:14 PM
D.Ilyin D.Ilyin is offline
 
Join Date: Oct 2005
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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?
Reply With Quote
  #2  
Old 05-06-2008, 09:59 PM
Farcaster Farcaster is offline
 
Join Date: Dec 2005
Posts: 386
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 05-06-2008, 11:40 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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";
Reply With Quote
  #4  
Old 05-07-2008, 08:36 AM
D.Ilyin D.Ilyin is offline
 
Join Date: Oct 2005
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #5  
Old 05-07-2008, 09:06 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 05-07-2008, 09:25 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, I didn't know he was doing a function.
Reply With Quote
  #7  
Old 05-07-2008, 09:55 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Boofo View Post
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.
Reply With Quote
  #8  
Old 05-07-2008, 10:37 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #9  
Old 05-07-2008, 10:42 AM
D.Ilyin D.Ilyin is offline
 
Join Date: Oct 2005
Posts: 193
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
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 04:27 PM.


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.04268 seconds
  • Memory Usage 2,259KB
  • Queries Executed 13 (?)
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
  • (7)bbcode_php
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete