Search code examples
templatesincludevbulletin

Including template inside global template in VBulletin


I need to do something like this in VBulletin. There should be several templates (I added them through admincp), that should be "included" in the global template called "footer". In fact only one of them should be included depending on somecondition. So in this footer I have

<vb:if condition="$my_variable == 1">
    <p>CASE_1</p>
<vb:elseif condition="$my_variable == 2" />
    <p>CASE_2</p>
<vb:else />
    <p>CASE_3</p>
</vb:if>

So in this if cases I need to change the CASE-s with a code to include other templates (i.e. "footer1", "footer2", "footer3").

Is there a way to do that?


Solution

  • Ok, I have done this by creating a template, passing the variables to it, rendering it and preregistering in the footer template like this (class_bootstrap.php):

    $templater = vB_Template::create('footer_'.$extension);
    $templater->register('admincpdir', $admincpdir);
    ...
    
    $includable_footer = $templater->render();
    vB_Template::preRegister('footer',array('included_footer ' => $includable_footer));
    
    $templater = vB_Template::create('footer');
    $templater->register('included_footer', $includable_footer);
    $footer = $templater->render();
    

    And in the footer template inserted this line:

    {vb:raw included_footer}