问题
This question is a reformulation of this question which had evolved in a confusing way. Please refer to this question if you search some in depth details or are interested in workarounds and alternative solutions.
This question is about the call to template folder_full_view_item.pt
in folder_full_view.pt
, not about other templates in general!
Please avoid workarounds like skin layers, editskinswitcher, etc. I don't want to solve a particular use case here. What I want is to really understand how this actually works.
I present this question in three parts: scenario, result, questions.
scenario
Have a Folder with a Document. The layout of the Folder is folder_full_view
. The layout of the Document is document_view
:
Folder (layout=folder_full_view)
Document (layout=document_view)
The template folder_full_view.pt
calls template folder_full_view_item.pt
via item.getObject().folder_full_view_item()
.
folder_full_view_item.pt
calls (e.g. for a Document content type ) the template document_view.pt
via use-macro="item_macro"
(item_macro
being something like here/document_view/macros/content-core
). Schematically as follows:
folder_full_view.pt :: item.getObject().folder_full_view_item()
folder_full_view_item.pt :: use-macro="here/document_view/macros/content-core"
document_view.pt
In a plone3_theme
have overriden versions of the templates folder_full_view.pt
, folder_full_view_item.pt
, and document_view.pt
. These templates are registered as follows in configure.zcml
.
<browser:page
for="*"
name="folder_full_view_item"
template="folder_full_view_item.pt"
layer="example.theme.browser.interfaces.IThemeSpecific"
permission="zope2.View"
/>
<browser:page
for="Products.ATContentTypes.content.folder.ATFolder"
name="folder_full_view"
template="folder_full_view.pt"
layer="example.theme.browser.interfaces.IThemeSpecific"
permission="zope2.View"
/>
<browser:page
for="Products.ATContentTypes.content.document.ATDocument"
name="document_view"
template="document_view.pt"
layer="example.theme.browser.interfaces.IThemeSpecific"
permission="zope2.View"
/>
results
With the theme installed the results are:
Document and Folder get their templates (I guess) via traversal. The (sub)templates though don't go through the traversal.
Folder: uses overriden folder_full_view.pt
, original folder_full_view_item.pt
, and original document_view.pt
Document: uses overriden document_view.pt
questions
is it the case that
item.getObject().folder_full_view_item()
doesn't go through traversal? If yes why?what can be modified (in
folder_full_view.pt
!) to force a traversal to the overridenfolder_full_view_item.pt
(!) and subsequently to the overridendocument_view.pt
? Is this possible?
Again, please avoid workarounds like skin layers, editskinswitcher, etc. I don't want to solve a particular use case here. What I want is to really understand how this actually works.
来源:https://stackoverflow.com/questions/23809810/how-to-override-template-folder-full-view-item-pt