PDA

View Full Version : vBuletin template variables for dummies


Mark Hewitt
01-16-2011, 10:10 AM
In vb3 I have some code in forumdisplay PHP within the while loop that displays threads

if($thread[forumid] = 98 ) {
$forumname = "[WRC]";
}


Then in the template just has $forumname in the appropriate place and that's all fine.

Of course in vb4 it's all different and I've followed about 5 different guides as to how to do it, and nothing is producing any results! Mostly because they all refer to custom templates and custom scripts. What I want to do is modify an existing file and output to an existing template.

I've tried the $tempplater->register('forumname',$forumname); , doesn't work when I put {vb:raw forumname} into the template.

Could anyone explain how to do it very simply - I've read the guides, they don't seem to work for me.

Thanks

Sarteck
01-16-2011, 10:22 AM
Let's say you want the template my_template to be modified with your variable.

vB_Template::preRegister('my_template',array('foru mname' => $forumname));


Replace "my_template" with your template name, and make sure that $forumname has a value where you do this. (You can generally put this as code in the process_templates_complete hook.)

--------------- Added 1295180827 at 1295180827 ---------------

Strike that "process_templates_complete" -- I meant "parse_templates" X3

Mark Hewitt
01-16-2011, 11:14 AM
Aha! Works, many thanks for that. I knew it'd be simple!

Sarteck
01-16-2011, 11:18 AM
No prob, I was in the same situation when I switched to vB4. X3