Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 372 Vote(s) - 3.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WHMCS Addon Module admin section template

#1
I can't find it anywhere in the developer documentation but it does hint to the fact that in the _output function of an admin addon module I can call a template file.

How do I do this? I would like to call a template file for final output from the module directory to display my content in.

WHMCS v5.1.2 by the way.
Reply

#2
If we use `get_defined_constants()` in our addon module we see, for example:

[SMARTY_DIR] => /var/www/vhosts/domain.com/httpdocs/whmcs/includes/smarty/
[SMARTY_CORE_DIR] => /var/www/vhosts/domain.com/httpdocs/whmcs/includes/smarty/internals/
[SMARTY_PHP_PASSTHRU] => 0
[SMARTY_PHP_QUOTE] => 1
[SMARTY_PHP_REMOVE] => 2
[SMARTY_PHP_ALLOW] => 3

Meaning Smarty is already initialised in the admin area. All that's left is to create our template files and include them (in a `templates` subdir in your addon folder if you want to keep to a smarty standard).

Modify the following for your `_output` function:

$smarty = new Smarty();
$smarty->assign('myvar', 'World');
$smarty->caching = false;
$smarty->compile_dir = $GLOBALS['templates_compiledir'];
$smarty->display(dirname(__FILE__) . '/templates/mytemplate.tpl');

All that's left is the contents of your template file `mytemplate.tpl`, but you know this part already...

<p>Hello {$myvar}!</p>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through