Many thanks. Short, to the point and very helpful. Chris.
(04-03-2015, 03:56 PM)CroNiX Wrote: I use a templating system that I've built that includes an asset manager so you can inject css/js/meta tags, etc, into the head of the document from the controller. But in short:
View:
Code:
<head>
//load jquery
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript" charset="utf-8"></script>
//load stuff from the controller
<?=$head; ?>
</head>
Controller:
Code:
//load a js file
$data['head'] = '<script src="/js/somejs.js" type="text/javascript" charset="utf-8"></script>';
//set a js var!!
$data['head'] .= '<script type="text/javascript">var variable ="hello";</script>';
//load some css!!
$data['head'] .= '<style type="text/css">@import url("/css/main.css");</style>';
$this->load->view('your_view', $data);