简体   繁体   中英

How can I beautify asset URLs in Yii?

Yii has a notion of assets -- resources such as images, stylesheets and javascript that belong to a module. To avoid naming conflicts among modules, Yii publishes a module's assets, on demand, to a uniquely-named subfolder of the web app's assets folder.

For example, the project that is auto-generated by yiic serves HTML pages that link to jquery as follows:

<script type="text/javascript" src="/www/myproject/assets/b420fe6b/jquery.js"></script>

How can I change "b420fe6b" into something more readable (while still getting the benefits of assets and modules)? I would like what people see in "view source" to be clean and readable, not just the source code on the server.

http://www.yiiframework.com/wiki/148/understanding-assets/

Yii docs explain these Asset urls to be " a unique name created by Yii in a way that won't conflict with any other module that publishes assets "

Looks like this is a feature that may not be able to be beautified due to its functional nature as serving as a unique identifier...

Update: However, if you are able to locate all places where your asset urls are referenced in your yii code (including finally the folder name itself) you might be able to change them to something easier on the eyes. ( Don't recommend it though as you never know what you might brake! -- and on the 1 in 10,000,000,000 chance that the next asset-url that yii creates is identical to the beautified one lol )

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