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)

grecostimpy 03-13-2010 12:48 AM

This is a great thread and I know I'm on the right track.

I am trying to add a custom profile field to the memberaction_dropdown template.

{vb:raw post.field5}

How would I register this to work in the memberaction_dropdown? It works on postbit (because I'm assuming it is registered)

Thanks again for a great write-up!

princeedward 03-13-2010 05:24 AM

Quote:

Originally Posted by cellarius (Post 2002436)
$loggedin.action or $loggedin.where are not valid PHP variables. I do not think that this is just a registering problem. You should probably open your own thread in the forums and explain exactly what and how you are trying to do.

hmmm...if you dont mind mate lookin on this THREAD please...it might give you slight idea what i'm trying to do...and hope you can throw me some hint and help...

thanks anyway for your time mate to reply on this...

best regards...

:p

gkaradagan 03-13-2010 04:13 PM

i want to do that some codes work in navbar template but same code dont work in header or navbar . for example how can i run vb:raw forum.title} in forumhome.lastpostinfo template ?

testbot 03-18-2010 01:16 AM

i'm a little confused on how to get my loops into the templates.

how would i get mypage.php:
Code:

while ($result = $db->fetch_array($results)){
        $something .= $result['field1'];
        $something2 .= $result['field2'];
}
$templater->register('something ', $something );

to show all looped values in mytemplate:
Code:

<ul>
START TO DISPLAY LOOPED DATA
<li>
{vb:raw something}
</li>
END TO DISPLAY LOOPED DATA
</ul>


LaCN 03-29-2010 03:42 PM

I've been trying like crazy... We need more turorials...
  1. How do I get my variable $my_own_var in an existing template, like footer ?
  2. How do I get an existing variable from an existing template (like $navbits from the navbar template) in an existing template like footer ?



@ vB staff: RTFM should be WTFM

masterross 03-29-2010 08:19 PM

Quote:

Originally Posted by LaCN (Post 2012352)
I've been trying like crazy... We need more turorials...
  1. How do I get my variable $my_own_var in an existing template, like footer ?

use vB_Template::preRegister

Quote:

Originally Posted by LaCN (Post 2012352)
  1. How do I get an existing variable from an existing template (like $navbits from the navbar template) in an existing template like footer ?


@ vB staff: RTFM should be WTFM

you should register again existing vars:

$templater->register('navbits', $navbits);

LaCN 03-31-2010 11:08 AM

Thanks a bunch for the reply :) :)

Quote:

Originally Posted by masterross (Post 2012498)
use vB_Template::preRegister

Would this be needed to be doing in the hook location where it starts creating the footer ?
And in the case of the footer template, which has no hook-location, which hook location is best used ?

Quote:

Originally Posted by masterross (Post 2012498)
you should register again existing vars:

$templater->register('navbits', $navbits);

If the creating of the template navbar was done before the footer, would I pre-register the $navbits using the the hook-location in the "navbits_complete" ?

And if the navbar template was built after the footer, in which hook-location would I need to pre-register the $navbits ?

Thanks !

derfelix 03-31-2010 12:12 PM

as far as I have seen, footer template is created at the moment any other template is done...

example:
if at the top of a file.. before you did any template stuff...
you do
PHP Code:

echo $footer; exit; 

you will get a blank page...
but if you do:
PHP Code:

$templater vB_Template::create('anytemplate')->render();
echo 
$footer; exit; 

the footer template will show...
--> so just find a place before the first template is created...

Felix

pneo 03-31-2010 06:49 PM

Please can somebody help, I just can't figure out what I'm doing wrong.

I'm trying to add to FORUMHOME and I can't get the basic example working.

I've created a new plugin (hook: forumhome_start) with the following PHP code:

PHP Code:

$my_var 'abc';
$templater vB_Template::create('mytemplate');
$templater->register('my_var'$my_var);
$templatevalues['my_insertvar'] = $templater->render();
vB_Template::preRegister('FORUMHOME'$templatevalues); 

I've then added the following to the FORUMHOME template:

PHP Code:

<p>{vb:raw my_insertvar}</p


Am I right in expecting <p>abc</p> to appear in my forum home page source? Because I just get empty <p></p>, i.e. the variable doesn't exist.

I've tried different hook locations. I also tested the forumhome_start location by adding an "echo 'abc'; in the plugin php, and as expected "abc" appears right at the top of my forum home source.

What am I doing wrong? :S



EDIT!:: Apologies, missed this post: https://vborg.vbsupport.ru/showpost....1&postcount=72

masterross 03-31-2010 08:04 PM

As you wrote it you should use my_var first in template mytemplate.
Then when you use
<p>{vb:raw my_insertvar}</p> in FORUMHOME all content from mytemplate will be appear.


All times are GMT. The time now is 11:57 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.02099 seconds
  • Memory Usage 1,759KB
  • 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
  • (4)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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