How Do I Call a Variable From a vBulletin Plugin?

Registering variables in your vBulletin plugin lets you access them in the page's template or in another existing template. VBulletin is a popular commercial software package that helps you host a forum on your website. Before version 4 of vBulletin, it was possible to automatically access variables in templates. Since version 4 it's necessary to call the "preRegister" method to register variables with a specific template before you can access them.

Instructions

    • 1

      Open your vBulletin plugin with a text editor, such as Windows Notepad.

    • 2

      Declare variables and initialize them with values in your plugin by adding the following code:

      $my_str = "hi";
      $my_arr = array(
      'apple' => 'red',
      'banana' => 'yellow'
      );

    • 3

      Register your variables and save them into an array by adding the following code after the lines declaring your variables:

      $mytemplater = vB_Template::create('mytemplate');
      $mytemplater->register('my_str', $my_str);
      $mytemplater->register('my_arr', $my_arr);
      $myrendervar = $mytemplater->render();
      vB_Template::preRegister('FORUMHOME',array('myrendervar ' => $myrendervar));

      The "preRegister" method ensures that your data passes to an existing template before it's rendered. Replace "FORUMHOME" with the template you want to pass the data to.

    • 4

      Save the vBulletin plugin and close the file.

    • 5

      Open the source file of the template you preregistered the variables to in a text editor, such as Windows Notepad.

    • 6

      Access your variables by adding the following code in your template file:

      {vb:raw myrendervar}

    • 7

      Save the template file. Upload both files to the forum's server to update the plugin and template.

Related Searches:

References

Comments

Related Ads

Featured