[eluser]a&w[/eluser]
One other thought/observation.
Had you considered including the ability Rick Ellis's asset_helper includes whereby you can optionally specify a 'module'?
So in controller:
Code:
//current code would do:
$this->assetlibpro->add_js('/assets/js/base.js');
$this->assetlibpro->add_js('/assets/modules/module1/js/spiffy.js');
//with 'helper' could do:
$this->assetlibpro->add_js('base.js');
$this->assetlibpro->add_js('spiffy.js','','module1');//empty string for backward
//compatibility for 'group'
To do that add this method to library:
Code:
/**
* Get location of asset
* @access private
* @param string the name of the file or asset relative to configured assets folder
* @param string optional, module name
* @param string the asset type (name of folder within module name)
* @return string relative path to asset
**/
private function _asset_loc($asset_name, $module_name = NULL, $asset_type = NULL)
{
$asset_location = $this->asset_dir;//new config
if(!empty($module_name)):
$asset_location .= 'modules/'.$module_name.'/';
endif;
$asset_location .= $asset_type.'/'.$asset_name;
return $asset_location;
}
And then modify the existing methods slightly:
Code:
// function add_js($file, $group = '') {
/*mod*/
function add_js($file, $group = '', $module_name = NULL) {
/*mod*/
if (empty($group))
$group = $this->default_group_js;
if (!is_string($group))
return FALSE;
/*new*/
$file_loc = $this->_asset_loc($file, $module_name, 'js');
/*new*/
/*mod*/
$this->_add($file_loc, $group);
/*mod*/
//$this->_add($file, $group);
}
Assumed new config property:
Code:
/*
|--------------------------------------------------------------------------
| Asset storage
|--------------------------------------------------------------------------
|
| The path to where to storage the joined assets.
| alp_cache_dir_css = "/assets/compressed/" (as example)
|
*/
$config['alp_asset_dir'] = '/assets/';//TRAILING SLASH! <----------------new
$config['alp_cache_dir_css'] = '/assets/compressed/';//TRAILING SLASH!
And just modify the beginning of the class as so:
Code:
/*new*/
var $asset_dir = '';
/*new*/
var $cache_dir_css = '/';
var $cache_dir_js = '/';
var $cache_file_css = '';
var $cache_file_js = '';
var $gzip_compress_css = TRUE;
var $gzip_compress_js = TRUE;
var $force_cache_css = TRUE;
var $force_cache_js = TRUE;
function __construct() {
$this->CI = get_instance();
log_message('debug', 'Assetlibpro library loaded');
$this->default_group_css = $this->CI->config->item('alp_default_group_css');
$this->default_group_js = $this->CI->config->item('alp_default_group_js');
/*new*/
$this->asset_dir = $this->CI->config->item('alp_asset_dir');
/*new*/
Similar modification for add_css...
Seems like there would be a way to use the 'module' might be a way to provide a quick mechanism for switching (css) 'themes'. Probably more to it since I guess there may need to be folders for assets/compressed/themeName/.
Anyway, just sharing the thought...