Plon 3:覆盖默认的 Javascript 文件
我正在使用 Plone 3,目前正在尝试覆盖默认的 javascript 文件之一,即 table_sorter.js。
在我的产品的浏览器目录下,我创建了一个目录“javascripts”(只是为了让事情井井有条),然后在configure.zcml中将该目录注册为资源:
<browser:resourceDirectory
name="myproduct.javascripts"
directory="javascripts"
layer=".interfaces.IThemeSpecific" />
其中“myproduct”是不言自明的。 然后在 jssregistry.xml 中,我注册并订购了 javascript 文件:
<javascript id="++resource++myproduct.javascripts/table_sorter.js"
enabled="True"
cookable="False"
inline="False"
insert-after="jquery.js" />
其中 table_sorter.js 是我需要覆盖的 javascript 文件的名称。
我需要覆盖该文件的原因是因为默认情况下无法告诉用户表是否可排序,直到单击它为止。默认情况下,我需要在表标题上包含图标。
我已按照上述步骤操作,但似乎不起作用。我不知道我哪里错了。任何帮助将不胜感激。
I am using Plone 3 and currently trying to override one of the default javascript files i.e. table_sorter.js.
Under the browser directory of my product, I created a directory "javascripts" (just to keep things organized), then registered the directory as a ressource, in configure.zcml:
<browser:resourceDirectory
name="myproduct.javascripts"
directory="javascripts"
layer=".interfaces.IThemeSpecific" />
Where "myproduct" is self explanatory.
Then in jssregistry.xml, I registered and ordered the javascript files:
<javascript id="++resource++myproduct.javascripts/table_sorter.js"
enabled="True"
cookable="False"
inline="False"
insert-after="jquery.js" />
Where table_sorter.js is the name of the javascript file that I need to override.
The reason I need to override the file is because the default has no way of telling the user whether a table is sortable or not until it is clicked on. I need to include icons on the table header by default.
I have followed the above steps but it does not seem to work. I have no idea where I'm going wrong. Any help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少通用设置导入步骤。使用以下代码将文件 Skins.xml 添加到您的 gs 配置文件中:
之后,请记住重新安装您的产品,以便应用新的 gs 步骤
注意:我给出另一个答案只是因为注释中的代码不可读。查看@Martijn Pierters 的初始部分的答案(和评论)。
You are missing the generic setup import step. Add a file skins.xml to your gs profile with this code:
After that, rembember to reinstall your product in order to apply your new gs step
Note: I'm giving another answer simply because code in comments isn't readable. Look at the @Martijn Pierters 's answer (and comments) for the initial part.
您并没有覆盖原始 JavaScript 文件,只是添加了一个新文件。
您可以在这里执行两种不同的操作:
从portal_javascript 中删除原始的table_sorter.js:
由于原来的table_sorter.js文件是通过皮肤层来服务的,所以你可以在自己的皮肤层中放置一个同名的新文件来实现覆盖原来的。
You are not overriding the original JavaScript file, only adding a new one.
You can do two different things here:
Remove the original table_sorter.js from portal_javascript:
Because the original table_sorter.js file is server through a skin layer, you can put a new file with the same name in your own skin layer to override the original.
考虑到您已经将自定义的 javascript 文件放入静态目录中,请执行以下操作。
在文件“your/app/profiles/default/jsregistry.xml”中
根据需要修改属性。 :)
Considering that you have already placed your customised javascript file into your static directory, do as follows.
In file "your/app/profiles/default/jsregistry.xml"
Modify the attributes as you wish. :)