View Full Version : $header and CMS

17 Nov 2009, 07:18
I have at global_start (also tried all different global)

$templater = vB_Template::create('vbcart_livecart');
$templater->register('memberarea', $memberarea);
$livecart .= $templater->render();
$header .= $livecart;

That displays the cart contents in every single page of the site, except the CMS pages.

What am doing wrong?

18 Nov 2009, 00:38
You can't call anymore $header like that.

Replace the last line by this:

vB_Template::preRegister('header', array('livecart' => $livecart));

And add this at the end of the header template:

{vb:raw livecart}

Don't tested it, but it should work.

18 Nov 2009, 00:48
Thanks but that no longer displays anywhere with that method. Also I was trying to avoid a template edit

18 Nov 2009, 00:59
Here is the full code that works. When I switch the commenting for last line it no longer displays anywhere.

When I keep it as it is, it displays in all pages except the CMS pages

if ($ccount)

$templater = vB_Template::create('vbcart_livecart2');
$templater->register('ctotal', $ctotal);
$templater->register('ccount', $ccount);
$templater->register('myitem', $myitem);
$livecart = $templater->render();
} else
$memberarea = '';
if (is_member_of($vbulletin->userinfo, $vbulletin->options[covercart_usergroup]))
$templater = vB_Template::create('vbcart_livecartmemberarea');
$templater->register('memberarea', $memberarea);
$memberarea = $templater->render();
$templater = vB_Template::create('vbcart_livecart3');
$templater->register('memberarea', $memberarea);
$livecart = $templater->render();
$header .= $livecart;
//vB_Template::preRegister('header', array('livecart' => $livecart));

I am basically done converting this mod except for that and some peculiar tab situation

18 Nov 2009, 02:28
Lionel you code is ok. The problem is simple, global_start is not called in CMS.
Use process_templates_complete hook with your code.

18 Nov 2009, 02:47
Makes sense. But then, what is being called? I tried global_state_check which I know works everywhere, but that gives me other errors.

--------------- Added 17 Nov 2009 at 21:49 ---------------

hehehe did not fully read you.... (actually I only read your first reply from email, before adding the suggestion) that hook you suggested is perfect ... thanks!!!

Now I have to tackle that tab in profile