English 中文(简体)
FuelPHP Assets in subfolders
原标题:
  • 时间:2011-06-12 22:06:34
  •  标签:
  • fuelphp

Is it possible to use Assets to include files that are in sub folders?

Example: [base_url] /assets/css/pepper-grinder/jquery-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.





相关问题
How do you work with a single ORM query result in FuelPHP?

I have a query that is returning a single result and I m wondering if there s a way to access the properties of that result without having to loop through it since I am limiting it to a single result. ...

Getting FuelPHP observers to use MySQL datetimes

I was trying to get the FuelPHP ORM Observers to use MySQL datetimes rather than unix timestamps, however I can t figure out how to use the code provided in the docs. They provide this code: Orm...

OOP used in FuelPHP

I m trying to undestand how FuelPHP was written.. And since I don t know OOP much, I m puzzled when this class: https://github.com/fuel/core/blob/master/classes/date.php Here are methods that I don t ...

FuelPHP - Agent::is_mobile() memory inquiry

I been testing is_mobile(): if (Agent::is_mobile()) { $content = View::factory( mobileviewname ); } else { $content = View::factory( standardviewname ); } PHP profiler reports it taking up ...

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/jquery-ui-1.8.11.custom.min.css

identity conditional "===" , performance, and conversion

I ve always came away from stackoverflow answers and any reading I ve done that "===" is superior to "==" because uses a more strict comparison, and you do not waste resources converting value types ...

Fuelphp Asset:: error

Just testing out Fuelphp.. was wondering if anyone is aware of the issue with Asset:: call I implemented it in a template and got an error ( error view : url ) thanks ps: I guess i need to set Asset:...

How do I insert a NULL value in FUEL / ActiveRecord

Brief forward: I tried to ask this on the FUEL forums, but every time I try and register, their forum says "Failed sending activation email" and I can t log in or reset my account. So hopefully folks ...

热门标签