Feature Requests
Share ideas, discuss and vote on requests from other users in community
This object is in archive! 

Ability to work with Templates for the Admin Area in Addon Modules and Widgets

Seb shared this idea 3 years ago
Under Consideration

I stumbled upon this while developing an Addon and a Widget.

While it is possible to use templates for the Client Area, it is not for the Admin Area.

I circumvented this by running my own instance of smarty:

function myaddon_output($vars) {...$smarty = new Smarty();

$smarty->template_dir = __DIR__.'/templates';

$smarty->compile_dir = __DIR__.'/../../../templates_c';

$smarty->assign("foo", $bar);

$smarty->display("mytemplate.tpl");}And in the widget:function widget_monitoring($vars) {...$smarty = new Smarty();

$smarty->template_dir = __DIR__.'/../addons/myaddon/templates';

$smarty->compile_dir = __DIR__.'/../../../templates_c';

$smarty->assign('foo', $bar);

$content = $smarty->fetch("mytemplate.tpl");

return array( 'title' => 'My Widget', 'content' => $content );

}So it works, but maybe it would be nicer if WHMCS provided this functionality out of the box.

Working with HTML within PHP is just a pain...