News:

Wondering if this will always be free?  See why free is better.

Main Menu

Global Question

Started by The Wizard, November 16, 2012, 11:50:50 AM

Previous topic - Next topic

The Wizard

Do I need to use any globals to call up loadTemplate or not? The little voice in the back of my head says no, but who is to say the voice is right?


// Function Wizard: Loads the wizard template file

function wizard_popup ()
{

// Globals

global $smcFunc;

// this command loads the template file (wizard_popup.template.php)

    loadTemplate('wizard_popup');

} // End of Function wizard bracket



Wiz

All Colours Sam

The file that holds loadTemplate() func its loaded on every instance of SMF, meaning you don't need to require any file to use it.

As per globals, that only affects variables, not functions, if you need to use some var like $context then you must globalize this var before you can use it.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

The Wizard

So I don't need to use any globals and code should look like this -


// place this file in the Sources file

    if (!defined('SMF'))
            die('Hacking attempt...');

// Function Wizard: Loads the wizard template file

function wizard_popup ()
{

// this command loads the template file (wizard_popup.template.php)

       loadTemplate('wizard_popup');

} // End of Function wizard bracket

All Colours Sam

yep, providing your file is been running inside SMF atmosphere, if you're gonna use your file as an external standalone one then requiring SSI.php before anything else should be enough.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: