How to override template “folder_full_view_item.pt”?

只谈情不闲聊 提交于 2019-12-11 04:15:01

问题


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

  1. is it the case that item.getObject().folder_full_view_item() doesn't go through traversal? If yes why?

  2. what can be modified (in folder_full_view.pt!) to force a traversal to the overriden folder_full_view_item.pt(!) and subsequently to the overriden document_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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!