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

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2012, 01:23 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using custom phrasegroups in a plugin in VB4?

Been searching for this answer for a while... Quite a few old threads about this but from the VB 3.5 and 3.6 days...

Apparently you used to just add this code to init_startup hook:

Code:
$phrasegroups[] = 'groupname';
but it's not working for me ON VB 4.1.11.

I can use the phrasegroup on a custom php page by having this code near the top:
Code:
$phrasegroups = array('groupname');
Which is basically just another way of writing the same code as above- that works fine.

However neither works on init_startup.

Any ideas on this?
Reply With Quote
  #2  
Old 04-07-2012, 02:44 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hook: global_bootstrap_init_start

Code:
global $phrasegroups;
$phrasegroups[] = 'dbtech_vbanalytics';
Sucks you have to use global, but maybe there's a better way.
Reply With Quote
  #3  
Old 04-07-2012, 09:49 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

global_bootstrap_init_start would be better actually since $vbulletin->options is available so I could limit it to only when the mod setting that required it was enabled.

However it just isn't working.

This is what I have in global_bootstrap_init_start:

Code:
global $phrasegroups;
$phrasegroups[] = 'bop5';
And then in process_templates_complete I have this:

Code:
global $vbphrase;

echo "<pre>";
print_r ($vbphrase);
echo "</pre>";
die();
But none of the phrases from the 'bop5' group are printed out. Am I missing something?

EDIT- very weird as it is listed as an available phrasegroup in the debug info
Reply With Quote
  #4  
Old 04-07-2012, 11:47 AM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Dug in a bit. That will indeed add that phrasegroup to the array which ini's $vbphrase, however, for some odd reason, at that moment $vbulletin->userinfo contains elements "phrasegroup_x" full of serialized array values which are unset after $vbphrase is created. This is called in fetch_userinfo which is called includes/init.php. This all happens before that hook.

Hook: fetch_userinfo_query
PHP Code:
global $phrasegroups;
$phrasegroups[] = 'posting'
I honestly think there's got to be a better way. I don't like hooking into there and I don't think it would work unless you're logged in. I got sick of digging though, I'll probably come back to it later.
Reply With Quote
  #5  
Old 04-07-2012, 12:33 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You're right, it does work when logged in, but not for guests.

Thank you for this- I will investigate too and let you know if I come up with something.
Reply With Quote
  #6  
Old 04-07-2012, 12:35 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Actually it was as simple as:

PHP Code:
global $phrasegroups;
$phrasegroups[] = 'x'
Thought I added a global when I checked it out earlier. -shrugs-

Works for logged-in and guests. Phrases get fetched when they're building sessions: fetch_language_fields_sql() method.
Reply With Quote
  #7  
Old 04-07-2012, 12:53 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

on what hook?

Right now I have

Code:
global $phrasegroups;
$phrasegroups[] = 'bop5';
on both fetch_userinfo_query and init_startup and it is working for both guests and members.


Edit- it seems I only need it on init_startup now... but I could have swotn I tried it already... oh well... many thanks.
Reply With Quote
  #8  
Old 04-07-2012, 01:00 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Just in init_startup.

Note of caution, be sure your phrasegroup is correct- or else you'll get a database error even within the ACP.
Reply With Quote
  #9  
Old 04-07-2012, 01:17 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Pandemikk View Post
Just in init_startup.

Note of caution, be sure your phrasegroup is correct- or else you'll get a database error even within the ACP.
good catch... I think I will us this just to make sure a db error in admincp can never happen...

Code:
if (defined('THIS_SCRIPT'))
{
  global $phrasegroups;
  $phrasegroups[] = 'bop5';
}
Since THIS_SCRIPT isn't defined in admin cp. :up:
Reply With Quote
  #10  
Old 04-07-2012, 01:19 PM
Pandemikk Pandemikk is offline
 
Join Date: Jul 2009
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Good call. I used a test phrase and had to unset it in the method.
Reply With Quote
Благодарность от:
BirdOPrey5
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 05:40 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.06366 seconds
  • Memory Usage 2,260KB
  • 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_code
  • (2)bbcode_php
  • (1)bbcode_quote
  • (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
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete