FuelPHP Assets in Subfolders

Can I use Assets to include files in subfolders?

Example: [base_url] /assets/css/pepper-grinder/jquery-ui-1.8.11.custom.min.css

+3
source share
3 answers

You can access the subfolders of an object / folder with this:

// Image in /assets/img1.jpg
print Asset::img("img1.png"); 

// Image in /assets/subfolder/img2.jpg
print Asset::img("subfolder/img2.jpg");
+3
source

In ./fuel/core/config/asset.phpyou can change the following code:

/**
 * An array of paths that will be searched for assets. Each asset is a
 * RELATIVE path from the base_url WITH a trailing slash:
 *
 * array('assets/')
 */
'paths' => array(''),

and

/**
 * Asset Sub-folders
 *
 * Names for the img, js and css folders (inside the asset path).
 *
 * Examples:
 *
 * img/
 * js/
 * css/
 *
 * This MUST include the trailing slash ('/')
 */
'img_dir' => 'img/',
'js_dir' => 'js/',
'css_dir' => 'css/'

If you configure pathson assetsand css_diron css/, you can enable [base_url] /assets/css/pepper-grinder/jquery-ui-1.8.11.custom.min.csswithecho Asset::css('pepper-grinder/jquery-ui-1.8.11.custom.min.css');

+2
source

Yup, you just set the paths in the asset.php file the way you like:

$config['asset_paths'] = array('assets/');

That is, if you want to use the Asset library. Otherwise, just make them absolute paths from webroot.

0
source

All Articles