Jump to content

Access GLOBALS values from index.tpl


Guillaume
 Share

Recommended Posts

Hi,

On the payment gateway I am developping, I am trying to define cool default values for the admin, so that they need to configurate only the very minimum.
In particular, for the return URL, I'd like to set a default value equal to
$GLOBALS['storeURL'] . '/modules/gateway/MyGateway/return.php'

But how can I access such a global variable from index.tpl? I have seen a couple of global variables being called in index.tpl, e.g. $VAL_SELF, $SESSION_TOKEN, etc. but the naming did not seem to match what is used in php.

Appreciate any help! Best regards,
Guillaume

Link to comment
Share on other sites

The Module class (/classes/module.class.php) takes care of a lot of the administrative functions of managing modules.

Let's take a quick look at the All-in-One-Shipping module.

In the module's shipping.class.php file, we see for example:

private $_group_name = "All In One Shipping";

Then, in the module's file /admin/index.inc.php, near line 33:

$module->module_settings_save($module->_settings);

We can add, just above that:

$module->_settings['group_name'] = $module->_group_name;

This allows us to specify certain settings in the class file or in the settings index file, but we need to call the Module class's 'module_settings_save()" function to record those settings.

The settings will end up in the Smarty array $MODULE.

Generally, there are no "global" variables with respect to Smarty templates. There must be some code in the PHP core files (possibly including such as the module's shipping class and the admin index file - but not really) that uses Smarty's assign() function to give values to template variables:

$GLOBALS['smarty']->assign('VAL_SELF','some_url_path');

However, the Module class takes care of things like this - assigning values to template variables. Look at the end of the module's admin settings index file:

$module->assign_to_template($template_vars, false);

 

Link to comment
Share on other sites

Cheers, I used the following in admin/index.inc.php:

$GLOBALS['smarty']->assign('STORE_URL', CC_STORE_URL);

And was eventually able to re-use it in skin/admin/index.tpl. For a reason I did not understand, I was not able to assign other variables. But I didn't investigate that much, as I have enough with $STORE_URL and $VAL_SELF

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...