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

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 02-29-2012, 08:22 AM
clubvr4's Avatar
clubvr4 clubvr4 is offline
 
Join Date: Jul 2010
Posts: 116
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default New Templates and registering variables

Hi all,

I could really do with some guidance, I'm struggling to understand the whole process of registering variables in templates.

I have managed to get my head round creating new templates and presenting them via plugin within one of the default templates, for example.

Plugin.
Hook Location - Parse Templates.
Title - CVR4_Menu
Code -
PHP Code:
$templater vB_Template::create('CVR4_Menu');
$CVR4_Menu $templater->render();
vB_Template::preRegister('navbar', array('CVR4_Menu' => $CVR4_Menu)); 
I now call this from within navbar template using {vb:raw CVR4_Menu}

This works, i created a menu and this is showing - everything is cool here.

Now, what i want to achieve (for starters) is present the notifications to this template, i.e. the notifications will be added to the CVR4_Menu Template.

I followed several guides - threads i read include.
But, i don't think im getting it, yet... What I did was as follows.

Plugin.
Hook Location - Parse Templates.
Title - CVR4_Menu
Code -
PHP Code:
$templater vB_Template::create('CVR4_Menu');
$CVR4_Menu $templater->render();
vB_Template::preRegister('navbar', array('CVR4_Menu' => $CVR4_Menu));
vB_Template::preRegister('navbar', array('notifications_menubits' => $notifications_menubits)); 
This didn't work, so i then create a much simpler version...

Plugin.
Hook Location - Parse Templates.
Title - CVR4_Menu_preregister_notifications
Code -
PHP Code:
vB_Template::preRegister('CVR4_Menu', array('notifications_menubits' => $notifications_menubits)); 
This also didnt work, but i noticed after much fiddling that if i change the pre-register (in above example) to navbar and place the notifications code in the navbar it works, just like in header.

It seems to be that the CVR4_Menu template needs to be registered just like the navbar template before it will accept the notifications variables, but i really don't know where to start.

I read in one of the above threads that you can define some variables, like..

PHP Code:
/* Some Code, setting variables, (multidimensional) array */
$my_var "abc";
$my_array = array(
        
'key1' => 'value1',
        
'key2' => array(
                '
key21' => 'value21',
                '
key22' => 'value22'
        '
)
    );

/* render template and register variables */
$templater vB_Template::create('mytemplate');
    
$templater->register('my_var'$my_var);
    
$templater->register('my_array'$my_array);
$templater->render(); 
But i dont understand what the keys or values would/should be nor can i get my head around the above example.

Could someone please help me figure this out, i'm sure it will click for me soon but just now i'm just not getting it.

Maybe a working (simple) example of how to get notifications working in a custom template would aid me in my quest to understand.


Thanks for reading (all my waffle)
Reply With Quote
 


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 12:18 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.08036 seconds
  • Memory Usage 2,723KB
  • 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
  • (2)bbcode_code
  • (9)bbcode_php
  • (11)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (13)post_thanks_box
  • (13)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (13)post_thanks_postbit_info
  • (13)postbit
  • (13)postbit_onlinestatus
  • (13)postbit_wrapper
  • (1)showthread_list
  • (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_threadedmode.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_threaded
  • showthread_threaded_construct_link
  • 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