简体   繁体   English

如何在Yii中美化资产URL?

[英]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. Yii有一个资产概念 - 属于模块的图像,样式表和javascript等资源。 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. 为了避免模块之间的命名冲突,Yii按需将模块的资产发布到Web应用程序资产文件夹的唯一命名子文件夹。

For example, the project that is auto-generated by yiic serves HTML pages that link to jquery as follows: 例如,yiic自动生成的项目提供链接到jquery的HTML页面,如下所示:

<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)? 如何将“b420fe6b”更改为更具可读性(同时仍然获得资产和模块的好处)? 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/ 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 " Yii docs解释这些资产网址是“ Yii创建的一个独特的名称,不会与任何其他发布资产的模块冲突

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. 更新:但是,如果您能够找到yii代码中引用资产网址的所有位置(最后包括文件夹名称本身),您可以将它们更改为更容易的眼睛。 ( 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 ) 不要推荐它,因为你永远不知道你可能会刹车! - 并且在10,000,000,000的机会中,yii创造的下一个资产网址与美化的lol相同

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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