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 11-23-2009, 03:52 PM
stevegrant stevegrant is offline
 
Join Date: Sep 2008
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Passing variables into custom templates

I'm creating a custom page (or rather a custom set of pages) that are referenced off the main navbar (thanks to the tutorial in the articles section on here ), but I don't seem to be able to get variables from $templater->register() to actually display within my template

Code extracts:

predictionleague.php
Code:
$navbits = array('prediction-league' => 'Prediction League');
$variable_to_pass = 'Passing through...';

$navbar = render_navbar_template(construct_navbits($navbits));
$templater = vB_Template::create('sweb_prediction_league');
  $templater->register_page_templates();
  $templater->register('navbar', $navbar);
  $templater->register('variable_to_pass', $variable_to_pass);
print_output($templater->render());
Template sweb_prediction_league:
Code:
...

<body style="text-align:left">

{vb:raw header}
{vb:raw navbar}
{vb:raw toolbar}

<div class="sweb_pl_block">
  <h1>{vb:raw variable_to_pass}</h1>
</div>
{vb:raw footer}
</body>
</html>
The bizarre thing is that the navbar modification (i.e. adding the breadcrumb trail) DOES get passed through and displayed correctly, but variable_to_pass doesn't!

Output:
Code:
<div class="sweb_pl_block">
  <h1></h1>
</div>
Any ideas?
Reply With Quote
  #2  
Old 11-23-2009, 04:36 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there anything in your error_logs? (If you don't know where they are, ask your host.)

You don't have toolbar registered either, is that showing up? Your code looks like it should be fine.
Reply With Quote
  #3  
Old 11-24-2009, 04:14 AM
stevegrant stevegrant is offline
 
Join Date: Sep 2008
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nothing in the error logs, and as it's currently running on localhost anyway, I'm outputting all errors and warnings to the screen.

Good spot on the toolbar, the joys of copy and paste - I don't actually need that one!

There's something very odd going on, I've also just had a fiddle around to see if I could still print_r the $vbulletin object before I run vb_Template::create but it now does nothing, and even commenting out the template commands at the end of the script has no effect - the template is still displayed!! Don't think it's a caching issue as I've cleared the cache a number of times...
Reply With Quote
  #4  
Old 11-24-2009, 10:05 PM
winstone winstone is offline
 
Join Date: Dec 2006
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try these files and see if it is working, its the first custom page I created following the tutorials here

upload the test.php into root of your forum, import the template.xml file (contains 3 custom templates named test, test_bit, loop_bit), then just open test.php file in browser

see if it is working
Attached Files
File Type: php test.php (2.2 KB, 19 views)
File Type: xml test-template.xml (1.5 KB, 12 views)
Reply With Quote
  #5  
Old 12-01-2009, 05:48 AM
stevegrant stevegrant is offline
 
Join Date: Sep 2008
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for your help - got it working in the end, although I haven't actually changed anything... slightly strange, but never mind!
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 12:55 AM.


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.06005 seconds
  • Memory Usage 2,215KB
  • Queries Executed 12 (?)
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
  • (3)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (2)postbit_attachment
  • (5)postbit_onlinestatus
  • (5)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_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
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete