[eluser]wiredesignz[/eluser]
There are probably nicer ways to do this without extending CI_Loader.
You could use an asset helper in your view which receives your dependency array and builds the links accordingly.
Example: application/helpers/asset_helper.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function asset($type = 'css', $assets = array(), $url = NULL, $crlf = "\n")
{
$str = '';
foreach ($assets as $source => $attrib)
{
$href = ($url) ? $url : base_url();
$source = $href . str_replace(".{$type}", '', $source);
switch ($type)
{
case 'css':
{
$str .= '<link rel="stylesheet" type="text/css" href="'.$source.'.'.$type.'" '.$attrib.' />'."\n";
break;
}
case 'js':
{
$str .= ''."\n";
break;
}
case 'img':
{
$str .= '<img src="'.$source.'" '.$attrib.' />'."\n";
break;
}
}
}
return $str;
}
function meta_tag($type, $content = array(), $crlf = "\n")
{
$str = '';
foreach ($content as $key => $value)
{
switch ($type)
{
case 'http':
{
$str .= '<meta http-equiv="'.$key.'" content="'.$value.'" />'.$crlf;
break;
}
case 'name':
{
$str .= '<meta name="'.$key.'" content="'.$value.'" />'.$crlf;
break;
}
}
}
return $str;
}
Note: the forums always break the code in the javascript part of the helper
Usage:
Code:
<?php
//uses asset_helper
echo meta_tag('http', array(
'content-type' => 'text/html; charset=UTF-8',
));
echo meta_tag('name', array(
'author' => 'Wiredesignz, <[email protected]>',
'robots' => 'index, follow',
'description' => $title,
));
echo asset('css', array(
'css/shop' => 'media="screen"',
'css/login' => 'media="screen"',
));
echo asset('js', array('js/shop_functions' => '',));
?>
The assets array could be passed into your view quite easily.