FuelPHP Assets in subfolders
Is it possible to use Assets to include files that are in sub folders?
Example: [base_url] /assets/css/pepper-grinder/jqu开发者_如何学JAVAery-ui-1.8.11.custom.min.css
You can access subfolders of the asset/ 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");
In ./fuel/core/config/asset.php
, you can alter 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 paths
to be assets
and css_dir
to be css/
, you can include [base_url] /assets/css/pepper-grinder/jquery-ui-1.8.11.custom.min.css
by using echo Asset::css('pepper-grinder/jquery-ui-1.8.11.custom.min.css');
Yup, you just set the paths in asset.php to whatever 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.
精彩评论