Welcome Guest, Not a member yet? Register   Sign In
Asset library
#1

[eluser]xtremer360[/eluser]
I'm in search of an asset library that I can tell it to add certain assets to the end of the list of assets already in my template view for specific controllers and or their methods. This way I don't have to load so many different scripts or css files for pages that don't need them and only load them when there is a need for them.
#2

[eluser]CroNiX[/eluser]
Sounds like an easy thing to add. Just pass an array of assets to your template and in the header template, in the head section, check to see if any were set. If so, output them.

Code:
$data['assets']['js'][] = 'http://yoursite.com/js/file1.js';

$this->load->view('your_view', $data);

Code:
<HEAD>
//load global js
<skript type="text/javascript" src="http://yoursite.com/js/my_common_js.js"></skript>

//load custom js
&lt;?php if (isset($assets['js']): ?&gt;
&lt;?php foreach($assets['js'] as $js_file): ?&gt;
<skript type="text/javascript" src="&lt;?php echo $js_file; ?&gt;" ></skript>
&lt;?php endforeach; ?&gt;
&lt;?php endif; ?&gt;

//same thing with CSS
&lt;/HEAD&gt;




Theme © iAndrew 2016 - Forum software by © MyBB