1 | README for the 'browser/scripts/' directory |
---|
2 | =============================================== |
---|
3 | |
---|
4 | This folder is a Zope 3 Resource Directory acting as a repository for |
---|
5 | scripts. |
---|
6 | |
---|
7 | Its declaration is located in 'browser/configure.zcml': |
---|
8 | |
---|
9 | <!-- Resource directory for scripts --> |
---|
10 | <browser:resourceDirectory |
---|
11 | name="${namespace_package}.${namespace_package2}.${package}.scripts" |
---|
12 | directory="scripts" |
---|
13 | layer=".interfaces.IThemeSpecific" |
---|
14 | /> |
---|
15 | |
---|
16 | A script placed in this directory (e.g. 'foo.js') can be accessed from |
---|
17 | this relative URL: |
---|
18 | |
---|
19 | "++resource++${namespace_package}.${namespace_package2}.${package}.scripts/foo.js" |
---|
20 | |
---|
21 | Note that it might be better to register each of these resources separately if |
---|
22 | you want them to be overridable from zcml directives. |
---|
23 | |
---|
24 | The only way to override a resource in a resource directory is to override the |
---|
25 | entire directory (all elements have to be copied over). |
---|
26 | |
---|
27 | A Zope 3 browser resource declared like this in 'browser/configure.zcml': |
---|
28 | |
---|
29 | <browser:resource |
---|
30 | name="foo.js" |
---|
31 | file="scripts/foo.js" |
---|
32 | layer=".interfaces.IThemeSpecific" |
---|
33 | /> |
---|
34 | |
---|
35 | can be accessed from this relative URL: |
---|
36 | |
---|
37 | "++resource++foo.js" |
---|
38 | |
---|
39 | Notes |
---|
40 | ----- |
---|
41 | |
---|
42 | * Scripts registered as Zope 3 resources might be flagged as not found in |
---|
43 | the 'portal_js' tool if the layer they are registered for doesn't match the |
---|
44 | default skin set in 'portal_skins'. |
---|
45 | This can be confusing but it must be considered as a minor bug in the JS |
---|
46 | registry instead of a lack in the way Zope 3 resources are handled in |
---|
47 | Zope 2. |
---|
48 | |
---|
49 | * There might be a way to interpret DTML from a Zope 3 resource view. |
---|
50 | Although, if you need to use DTML for setting values in a script (the |
---|
51 | same way as in default Plone scripts where values are read from |
---|
52 | 'base_properties'), it is much easier to store it in a directory that is |
---|
53 | located in the 'skins/' folder of your package, registered as a File System |
---|
54 | Directory View in the 'portal_skins' tool, and added to the layers of your |
---|
55 | skin. |
---|
56 | |
---|
57 | * Customizing/overriding scripts that are originally accessed from the |
---|
58 | 'portal_skins' tool (e.g. Plone default scripts) can be done inside that |
---|
59 | tool only. There is no known way to do it with Zope 3 browser resources. |
---|
60 | Vice versa, there is no known way to override a Zope 3 browser resource from |
---|
61 | a skin layer in 'portal_skins'. |
---|