PDA

View Full Version : Please help - using custom variables in template


Leonard
04-30-2010, 04:24 PM
Hi,

I'm now at wits end and despite reading the tutorials/articles, I cannot figure this out. I am not new to PHP and I'm not new to developing with VBUlletin, I'm trying to port an existing mod that I created over to VB 4.x.

Specifically, I have a template "newthread". I have declared a variable "$gallery_on = true;" in a plug-in that hooks into "newthread_start".

In the template "newthread", I have put in the following if/else conditional:

<vb:if condition="$gallery_on">
Gallery is on
<vb:else />
Gallery is off
</vb:if>

When I go to newthread.php, the template ALWAYS evaluates $gallery_on as FALSE. WHY!?!?:confused::confused:

ARGH. Help PLEASE. I know I'm just missing something so fundamental it's ridiculous.

Thanks,

Leonard

--------------- Added 1272649138 at 1272649138 ---------------

OMG HOURS of trying and finally figured it out. You have to register the custom variable for use in the respective template.

vB_Template::preRegister('newthread', array('gallery_on' => $gallery_on));

Is there no documentation for developers where all of this information lives? I'm sorry but I'm just so frustrated right now. Gosh.

NickyDee
04-30-2010, 05:40 PM
Glad you figured it out Leonard. We had about 5 years worth of material on vB 3.x.x so it was very easy finding things, vB 4 is very new and it will take time to build up a solid knowledge base.

This guide is where some of the info is: https://vborg.vbsupport.ru/showthread.php?t=228078