Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 04-14-2010, 08:13 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Getting foruminfo and bbuserinfo into the header template?

So I have my random header mod:
https://vborg.vbsupport.ru/showthread.php?t=212351

However, it doesn't work in VB4 because of the new template registration system. It looks like you can't call any of the foruminfo or bbuserinfo variables in the header. Is there any way I would be able to pull this info into the header, without having to do some php file editing? Maybe with some hooks?
Reply With Quote
  #2  
Old 04-15-2010, 01:24 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Have you looked at the header template? bbuserinfo is used several times in there, so I'm not sure why you would say you can't use it. You will probably have to preregister a forumid variable to use - see this article on that: [vB4] Rendering templates and registering variables - a short guide
Reply With Quote
  #3  
Old 04-15-2010, 02:04 AM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I got bbuserinfo working, but I can't get foruminfo working.

Is there any way I would be able to pull this info into the header, without having to do some php file editing? Maybe with some hooks?
Reply With Quote
  #4  
Old 04-15-2010, 03:18 AM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you read that article? Yes, you may use a hook to preregister the variable.
Reply With Quote
  #5  
Old 04-15-2010, 01:53 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of course I read the article, I read it weeks ago. It doesn't actually help me at this point as it doesn't answer my question. The article tells me how to render variables and templates in my own custom mods. It doesn't tell me how to use it in plugins.

What hook should I be using? What code should be in the plugin?
Reply With Quote
  #6  
Old 04-15-2010, 02:09 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No article is going to tell you what hook location to use. Go into debug mode and look at the list on the bottom of the page and use one of those. Better yet, find the area in the code you are need to target (in this case, your target is prior to the rendering of the header template, so find where it is rendered) and look for a hook that is rendered before that. And that article gives you an example of the code to preregister your variable right near the end:

Save into an array and preregister to use in an existing/stock template
PHP Code:
$templater vB_Template::create('mytemplate');
    
$templater->register('my_var'$my_var);
    
$templater->register('my_array'$my_array);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 
Reply With Quote
  #7  
Old 04-15-2010, 05:15 PM
Jaxel Jaxel is offline
 
Join Date: Sep 2005
Posts: 1,160
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, but that code just doesn't work for me... I tried the forumdisplay_complete hook (I know that $forumid exists at that location), and couldn't get it working...

Code:
$templater = vB_Template::create('mytemplate');
    $templater->register('forumid', $forumid);
$templatevalues['forum'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
Code:
{vb:var forum.forumid}

What is "mytemplate"? Basically, what it seems like, is that I need to find a hook AFTER $forumid has been set, but before the header template has been constructed. However, if $forumid isn't set before the header template is constructed, then this whole process is pointless. Looking through forumdisplay.php, I can't find where the header is being constructed, so who knows where the hell this needs to be. If the header is the first thing constructed, then it looks like I am shit out of luck.

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

Well i just tried the following at forumdisplay_start:

Code:
$templater = vB_Template::create('mytemplate');
    $templater->register('forumid', $vbulletin->GPC['forumid']);
$templatevalues['forum'] = $templater->render();
vB_Template::preRegister('header', $templatevalues);
Code:
{vb:var forum.foruminfo.forumid}
It seems like its already too late to register anything in the header, even at the start of forumdisplay. So basically as I said before, its IMPOSSIBLE to call in forum information in the header in VB4.

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

Honestly, looking at this whole methodology, it seems a bit messed up. It's not really a "solution", but more of a "workaround". You are creating a false template "mytemplate", which is used exactly NOWHERE in order to pass a small array. Its inefficient programming, a complete waste of resources and a demonstration of how things shouldn't be done. Its like this whole system was designed by game programmers.

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

Okay... it looks like my question is answered in the COMMENTS to the article, rather than the article itself...

Code:
$forum= array('forumid' => $vbulletin->GPC['forumid']);
vB_Template::preRegister('header',array('forum' => $forum));
forumdisplay_start
Reply With Quote
Reply

Thread Tools
Display Modes

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 06:40 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.04022 seconds
  • Memory Usage 2,222KB
  • 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
  • (5)bbcode_code
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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