PDA

View Full Version : Problem with template rendering


FatalBreeze
05-19-2010, 01:24 PM
Hello!
I wanted to post some statistics that are already shown in forumhome, in the footer:
so in forum.php (the hool is called: forumhome_complete) i typed this code:

$templatea = vB_Template::create('footer');
$templatea->register('numbermembers', $numbermembers);
$templatea->register('newuserinfo', $newuserinfo);
$templatea->register('totalposts', $totalposts);
$templatea->register('totalthreads', $totalthreads);
$templatea->render();

and in the footer template, i entered this code:

<div style="display: inline;">{vb:rawphrase threads} {vb:raw totalthreads}</div>
<div style="display: inline;">{vb:rawphrase posts} {vb:raw totalposts}</div>
<div style="display: inline;">{vb:rawphrase members} {vb:raw numbermembers}</div>
<div style="display: inline;">{vb:rawphrase welcome_to_our_newest_member_x, {vb:link member, {vb:raw newuserinfo}}, {vb:raw newuserinfo.username}}</div>


but when i refresh the browser i only see the phrases and not the values.
Can someone please explain how to fix this?

Thanks in advance.

Lynne
05-19-2010, 01:37 PM
The footer gets rendered when the global.php file gets included at the very, very top of the page. So, if you want to preregister some variables for use in the footer, you need to do so before the footer template is rendered.

FatalBreeze
05-19-2010, 02:04 PM
Thanks! but there's a problem:
I typed this in class_bootstrap.php:

// get total threads & posts from the forumcache
$totalthreads = 0;
$totalposts = 0;
if (is_array($vbulletin->forumcache))
{
foreach ($vbulletin->forumcache AS $forum)
{
$totalthreads += $forum['threadcount'];
$totalposts += $forum['replycount'];
}
}
$totalthreads = vb_number_format($totalthreads);
$totalposts = vb_number_format($totalposts);
// get total members and newest member from template
$numbermembers = vb_number_format($vbulletin->userstats['numbermembers']);
$newuserinfo = array(
'userid' => $vbulletin->userstats['newuserid'],
'username' => $vbulletin->userstats['newusername']
);


and it works! except for totalthreads and totalposts which contains the value 0.
I printed_r $vbulletin->forumcache, but there were no fields replycount and threadcount. How can i fix this?

Lynne
05-19-2010, 04:55 PM
Then I would guess you need to get the forumcache from datastore?