Q:

vBulletin 4.0 custom pages

I'm trying to make custom pages using the new vBulletin 4.
My PHP file uses the code below:
$templater = vB_Template::create('TEST');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
print_output($templater->render());

My template looks like this:
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
  <head>
    <title>{vb:raw vboptions.bbtitle} - {vb:raw pagetitle}</title>
    {vb:raw headinclude}
    {vb:raw headinclude_bottom}
  </head>
  <body>

    {vb:raw header}

    {vb:raw navbar}

    <div id="pagetitle">
      <h1>{vb:raw pagetitle}</h1>
    </div>

    <h2 class="blockhead">Title</h2>
    <div class="blockbody">
      <div class="blockrow">
        Text
      </div>
    </div>

    {vb:raw footer}
  </body>
</html>

My question relates to the use of one single template for around 50 pages, which used HTML and PHP together and were working in vBulletin 3.
Will I need to use a separate template for each custom page that I make from the existing pages? 
EDIT 1: I've opened a BOUNTY worth 100 points for this question. If you need any more details on my question, please leave a comment.
EDIT 2: Originally, I was using eval('$mytemplate = "' . fetch_template('mytemplate') . '";');  using vB3. This has broken the pages in vB4. If I follow ARandomOWI's post, will I be following the best approach?

A:

You can use the same template for all your custom pages if you only want to change some of the content between them.
In your PHP file you can pass variables to your template using:
$templater->register('var_name_used_in_template', $your_php_var);

This needs to be included before the "print_output" line. Then in your template you can add:
{vb:var var_name_used_in_template}

To display the contents of the variable "$your_php_var" that existed in the PHP. 
This way you can use "$your_php_var" to store some HTML to be displayed within your template. You can split the content between multiple PHP files or use a single file for all the content and use PHP conditionals to alter "$your_php_var".
Note: variables passed with "vb:var" are first put through the function "htmlspecialchars_uni()". If this causes problems, you can use "vb:raw" instead which passes the raw variable. Although, be sure that the variable has already been sanitized within the PHP file.
Hope that's clear enough.

