vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=242)
-   -   [HOW TO - vB4] Rendering templates and registering variables - a short guide (https://vborg.vbsupport.ru/showthread.php?t=228078)

Master Of Unive 04-06-2015 12:09 AM

I think using member_build_blocks_start is much better than member_complete as it allows you to access function preRegister of vB_Template class.

Gizmo99 05-15-2015 06:36 AM

JUst a quick question

Playing with 4.2.2

Tried using the $templater but no dice but (Sorted)

BUT !!!! eval does work ? is this right ?



PHP Code:

if ($_POST['do']  == 'start')
{
            eval(
'print_output("'fetch_template('online_menu') . '");');

// Template show
$templater vB_Template::create('online_menu');
$templater->register_page_templates();
print_output($templater->render());




Black Snow 05-15-2015 06:42 AM

Quote:

Originally Posted by Easy5s.net (Post 2538101)
hock process_templates_complete

PHP Code:

$templater vB_Template::create('testtest');
    
$templater->register('var1'$var1);
    
$templater->register('var2'$var2);
$out[test] = $templater->render();
$ad_location['global_below_navbar'] .= $out

but not work???. I want auto add temp to below navbar.

Try this:

Code:

$templater = vB_Template::create('testtest');
$templater->register('var1', $var1);
$template_hook[global_below_navbar] .= $templater->render();


taravasya 10-01-2015 08:23 AM

Help me please! What I`m do wrong?...
I trying show some info on showthread page.
-----------------------------------------------------------------
PHP Code:

<plugin active="1" executionorder="5">
    <
title>RightSideBlock</title>
    <
hookname>showthread_start</hookname>
    <
phpcode><![CDATA[
$mynewvar "MyNewVar";
$templater vB_Template::create('rightside_on_showthread');
    
$templater->register('mynewvar'$mynewvar);
$rightside_rendered $templater->render();
    ]]></
phpcode>
</
plugin

------------------------------------------------------------------
HTML Code:

<template name="rightside_on_showthread" templatetype="template" date="1337106668" username="taravasya" version="1.0.0"><![CDATA[
<div class="rightsideinfo">
{vb:raw mynewvar}</div>
]]></template>

------------------------------------------------------------------
And so on SHOWTHREAD template I adding:
HTML Code:

{vb:raw rightside_on_showthread}
------------------------------------------------------------------
But with no luck (((
In place in what I was want to add my info I have white space(without my div class="rightsideinfo" in inspector of page). But in debug info, I have not cached template rightside_on_showthread.

UPDATE -------------------------------------

I was thinking if I take vars into my own template, then I don`t need to use vB_Template:: preRegister for add my template in showthread. But I was wrong...))

Lynne 10-04-2015 02:46 PM

PHP Code:

$templater vB_Template::create('rightside_on_showthread');
    
$templater->register('mynewvar'$mynewvar);
$rightside_rendered $templater->render();
vB_Template::preRegister('SHOWTHREAD', array('rightside_rendered' => $rightside_rendered)); 


taravasya 10-15-2015 03:15 PM

Thanks, Lynne! Actually I wrote in a previous message, that I understood my mistake, but your variant helped me to make my code more succinctly! Thanks!

taravasya 10-29-2015 09:54 PM

Another problem(((
In hook showthread_similarthreadbit I add next code:
PHP Code:

        $templater vB_Template::create('rightside_similarthreadbit'); 
        
$templater->register('simthread'$simthread); 
        
$templatevalues .= $templater->render(); 
        
vB_Template::preRegister('SHOWTHREAD', array('templatevalues' => $templatevalues)); 

Like this I have just ONE LAST result from query. What I have to do for have all results?
This hook added in showthread.php on 1978.
I was thinking, if this hook placed in a while cycle, I will have all results from this cycle. But no.... :(

irantk 12-12-2018 06:42 AM

Hi
my plugin load in "showthread_complete" and it's code is:
PHP Code:

global $pagenumber$perpage$totalposts$pagetitle$threadinfo;

$totalpages ceil($totalposts $perpage);
$templater vB_Template::create('opengraph_inshowthread');
$templater->register('pagenumber'$pagenumber);
$templater->register('totalposts'$totalposts);
$templater->register('perpage'$perpage);
$templater->register('totalpages'$totalpages);
$templater->register('pagetitle'$pagetitle);
$templater->register('pagedescription'$threadinfo['description']);
$template_hook['headinclude_bottom_css'] .= $templater->render(); 

and "opengraph_inshowthread" template code is:
Code:

<meta property="og:title" content="{vb:raw pagetitle} - page {vb:raw pagenumber} of {vb:raw totalpages} pages" />
But nothing adds to head. how to add my template to head?
I need to point out that I can not load the plugin in the "parse_template". Because the page number and other variable is not recognized in "parse_template".
and why "{vb:rawphrase thread.title}" not work in my template?


All times are GMT. The time now is 03:55 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.01626 seconds
  • Memory Usage 1,767KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (2)bbcode_html_printable
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete