[eluser]Rudybg[/eluser]
Hi.
I use Modular Extensions HMVC and Template library by Phil Sturgeon.
How can I use $this->template in a module's controller. I want to load some module's javascript files in the head of the html layout with the append_metadata() method.
An example in order of execution:
controllers/home/home.php - the main controller
Code:
class Home extends MX_Controller {
function index()
{
$this->template->build('login');
}
}
views\layouts\default.php- the default layout
Code:
<html>
<head>
<?php include "\..\partials\head.php"; ?>
</head>
<body>
//calling topbar module
<?php echo Modules::run('navigation_panels/TopBar/render'); ?>
<?php echo $template['body']; ?>
</body>
</html>
modules\navigation_panels\controllers\TopBar.php- the topbar module's controller
Code:
class TopBar extends MX_Controller {
public function __construct()
{
parent::__construct();
//want to manipulate the head but template property is not visible
$this->template->prepend_metadata(generateJavaScriptIncludeTag('TOPBAR_JAVASCRIPT_LOCATION' . 'change_language.js'));
}
public function render()
{
$data['languages'] = $this->language->getOtherLanguageArray();
$this->load->view('TopBar_view', $data);
}
}