vBulletin 4 and the Magically Generated Templates

Just been converting some old vBulletin 3.6.x plug-ins to vBulletin 4.0.x and have run across a couple of gotchas.

Do you have problems like:

  • I can't add the output of a custom template to the footer template.
  • I add {vb:raw my_var} to the header and it does not appear on the page.
  • The data that I vB_Template::preRegister is wrong.
  • vBulletin 4 template upgrade problems.

The thing to note here is that when you render your own custom template, the header and footer templates are automatically rendered.  This means that you can not add you output from your custom template to the header of footer templates by using {vb:raw my_template_output}

Follow the example below to update the footer template.

    // Register my_var with the custom template
    vB_Template::preRegister('my_template', array('my_var' => $my_var));
    $templater = vB_Template::create('my_template');

    // Render the custom template
    $my_template_output = $templater->render();

    // Add the output from the template to the footer template
    $GLOBALS['footer'] .= $my_template_output;

As soon as a vB_Template object is created, the following templates are rendered:

  • headinclude
  • headinclude_bottom
  • header
  • footer

Without re-creating the templates again. It is better to append or prepend the data that you need.

I hope this helps somebody.

Advertisements

One response to “vBulletin 4 and the Magically Generated Templates

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s