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 12-01-2009, 08:20 PM
Seven Skins's Avatar
Seven Skins Seven Skins is offline
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Rendering Custom Template

I have tried following this: https://vborg.vbsupport.ru/showthread.php?t=228078 but no luck with what I am trying to do.
Most probably it will be simple solution but I can not get it to work. (I am new to writing plugins etc ...)

What I am trying to do is:

I have template name "TEST" with just simple HTML code <div>Some text</div>

And I just want this HTML to be inserted into e.g. footer template.

I have tried this in global_start plugin.

PHP Code:
$templater vB_Template::create('TEST');
$test $templater ->render();
vB_Template::preRegister('footer',array('test' => $test)); 
or

PHP Code:
$templater vB_Template::create('TEST');
$templatevalues['test'] = $templater->render();
vB_Template::preRegister('footer'$test); 
And this in footer template.

PHP Code:
{vb:raw test

But that template does not show in footer template.


Thanks

.
Reply With Quote
  #2  
Old 12-01-2009, 08:33 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you are creating a whole different footer template, then I would call it something else. The footer template gets rendering by the vbulletin engine very early on, and if you are using the same name, then you may get weird results.
Reply With Quote
  #3  
Old 12-01-2009, 08:47 PM
Seven Skins's Avatar
Seven Skins Seven Skins is offline
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, I just want to add something to footer template ... but need separate template for it, as this template will be edited frequently. I am working on a simple product which I will release here if successful

.
Reply With Quote
  #4  
Old 12-01-2009, 08:57 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, now I see what you are doing. I wasn't reading it correctly. The first code that you posted looks correct. However, what hook location are you using? As I said before, the footer template gets rendered at the very beginning (in the global.php file) and you may to render it again in order to get your stuff added.
Reply With Quote
  #5  
Old 12-01-2009, 09:07 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah, now I see what you are doing. I wasn't reading it correctly. The first code that you posted looks correct. However, what hook location are you using? As I said before, the footer template gets rendered at the very beginning (in the global.php file) and you may to render it again in order to get your stuff added.
Reply With Quote
  #6  
Old 12-01-2009, 09:17 PM
Seven Skins's Avatar
Seven Skins Seven Skins is offline
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have used global_start hook location.

This seems to add the data to footer with the above hook.

PHP Code:
$test "Some text here";
vB_Template::preRegister('footer',array('test' => $test)); 
But I need to add/render the template.

.

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

I have searched "class_bootstrap.php" and found that "parse_templates" was called just before header and footer templates got rendered.

"parse_templates" hook seems to work.

.
Reply With Quote
  #7  
Old 12-01-2009, 09:58 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

So let's see the code you are trying to use to render the template and then preregister it. And, look up where the footer template is rendered... the parse_templates hook is right above there. Have you tried it?
Reply With Quote
  #8  
Old 12-01-2009, 10:04 PM
Seven Skins's Avatar
Seven Skins Seven Skins is offline
 
Join Date: Sep 2008
Location: London, UK
Posts: 1,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yup, its working (As replied above)

Here is the code I used in "parse_templates" hook:

PHP Code:
$templater vB_Template::create('TEST');
$templatevalues['test'] = $templater->render();
vB_Template::preRegister('footer'$templatevalues);
vB_Template::preRegister('header'$templatevalues); 
And this in footer or/and header template:
PHP Code:
{vb:raw test

Thanks

.
Reply With Quote
  #9  
Old 04-27-2011, 04:02 PM
RagingPenguin's Avatar
RagingPenguin RagingPenguin is offline
 
Join Date: Mar 2008
Location: North Carolina
Posts: 42
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would one go about doing this in a way that would make a custom template available in all other templates, and not have to preRegister each of them?

Here's what I have so far.

cache_templates
PHP Code:
$cache array_merge($cache, array(
'layout_a',
'layout_b',
'layout_c',
'layout_d'
)); 
parse_templates
PHP Code:
global $layout_a$layout_b$layout_c$layout_d;
$layout_a vB_Template::create('layout_a')->render();
$layout_b vB_Template::create('layout_b')->render();
$layout_c vB_Template::create('layout_c')->render();
$layout_d vB_Template::create('layout_d')->render();

But I think it should be more like:

parse_templates
PHP Code:
global $layout_a$layout_b$layout_c$layout_d;
$layout_a vB_Template::create('layout_a')->render();
$layout_b vB_Template::create('layout_b')->render();
$layout_c vB_Template::create('layout_c')->render();
$layout_d vB_Template::create('layout_d')->render();

// for each cached template, global or otherwise, register
// the above templates as variables
foreach ($globaltemplates as $key => $value)
{
vB_Template::preRegister($key, array(
'layout_a' => $layout_a,
'layout_b' => $layout_b,
'layout_c' => $layout_c,
'layout_d' => $layout_d
)); 
I know it doesn't work, but that's because I'm not sure what array to use/globalize here.

Help?
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 09:23 PM.


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.05976 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
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
  • (9)bbcode_php
  • (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_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