简体   繁体   中英

How do I override physical asset paths in lithium li3

I'd like to override the paths lithium uses to retrieve assets but am not sure how to do that.

Using the Media::assets method doesn't seem to have any affect accept that it changes the Url that the Html::script helper uses.

How do I appropriately override the real path that lithium uses for assets? Below is an example of how I tried to override the asset paths for javascript files:

Media::assets('js', array(
    'suffix' => '.js',
    'filter' => null,
    'theme' => 'blue',
    'paths' => array(
        '{:base}/{:library}/themes/{:theme}/public/js/{:path}' => array('base', 'library', 'theme', 'path'),
        '{:base}/{:library}/themes/default/public/js/{:path}' => array('base', 'library', 'path')
    )
));

Can you elaborate more about what you mean by retrieving assets and real path?

Media::assets function does exactly what it is expected from it, to set the paths used by Media::asset() which is currently used by the default path handler in lithium\\template\\view\\Renderer . The problem is that the default path handler does not seem to pass a library option, so my guess is the {:library} token will always be replaced with the basename of your default library path.

I don't see why you would need to fiddle with the default paths though. Plus you can always use absolute path by adding / prefix when you use Html::script function.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM