Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Extending Core\Asset or adding a domain
  • Can I extend the Asset class or can I not override static methods? I want the ability to add_domain. I am serving my static assets from a different cookie-less subdomain which just points to my asset folder.Eg
    asset.root.com > /public/assets/
    asset.root.com/css/style.css === root.com/assets/css/style.css
    
    Would I need to just modify fuel/core/classes/asset.php ?
  • If you're on 1.1/develop, you can create multiple asset instances, each with it's own configuration.
  • Oh this is exactly what I wanted, thanks. I am trying to use it by setting the url, but it's appending /assets to the url.
    Asset::forge('custom',array('paths'=>array('assets/'),'url'=>'http://assets.domain.com/'));
    
    If I leave the paths out, it can't find the file locally.
  • As I wrote, the asset class supports multiple instances. So use something like:
    // create the remote and local instance
    Asset::forge('remote',array('paths'=>array(),'url'=>'http://assets.domain.com/'));
    Asset::forge('local',array('paths'=>array('assets/'),'url'=>'/'));
    
    // and use them
    echo Asset::instance('remote')->img('static/image.png');
    echo Asset::instance('local')->js('dynamic/script.js');
    
  • Yeah, I get that, but the problem is it's appending "assets/" to the url and it won't accept an empty array for 'paths'
    Asset::forge('remote',array('url'=>'http://assets.domain.com/'));
    echo Asset::instance('remote')->css('bootstrap.css');
    // Outputs:   http://assets.domain.com/[b]assets/[/b]css/bootstrap.css?1326604172
    // Expected: http://assets.domain.com/css/bootstrap.css?1326604172
    
    Or
    Asset::forge('local',array('paths'=>array('assets/'),'url'=>'/'));
    echo Asset::instance('local')->css('bootstrap.css');
    // Outputs:   /assets/css/bootstrap.css?1326604172
    
    Or
    Asset::forge('remote',array('paths'=>array(), 'url'=>'http://assets.domain.com/'));
    echo Asset::instance('remote')->css('bootstrap.css');
    // Error:  Could not find asset: bootstrap.css
    

    I need it to know that the actual file is in /assets but I don't want that included in the url. Do I need to modify the core file or is there an option for this?
  • I've just checked the code. The Asset class currently does not support a remote assets instance. It always checks for the file locally, unless the filename itself contains a scheme. Please create an issue for this on http://github.com/fuel/core/issues, so it can be fixed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion