Vbulletin adding PHP variables to templates

create a plugin with the following code assigned to the global_start hook:

<?php
$request_uri = ltrim($_SERVER['REQUEST_URI'], '/');
$another_variable = somecode();
vB_Template::preRegister('STANDARD_ERROR',array('request_uri' => $request_uri, 'vbvariable' => $another_variable));
vB_Template::preRegister('STANDARD_ERROR_LITE',array('request_uri' => $request_uri, 'vbvariable' => $another_variable));
?>

The variables must be included in each template that they will be used in (vb v4). In earlier versions, this wasn't necessary.

Include the output of the variable using {vb:raw varibale_name} like so:

<a href="/user?destination=forum?{vb:raw request_uri}" target="_top">Please login to view this page.</a>

Article Type

General