开发者

Replacement for getMainTemplate override in Plone 4+

In an older site we are migrating from Plone 2 to Plone 4, we've overridden the main template used for a particular Archtypes-based content type using a getMainTemplate method defined on the content type:

def getMainTemplate(self):
    """ this defines the main template to use in base_edit/view/etc for this
    item of content """
    return 'a_different_main_template'

In Plone 4, this no longer seems to work. A pdb in the method isn't hit, so presumably this has been removed. Probably for good reason, as this kind of model/view mixing seems messy.

I have tried following the instructions from http://plone.org/documentation/manual/theme-reference/buildingblocks/skin/templates/how-to-customise-view-or-edit-on-archetypes-content-items to override the edit form, but can't understand how one goes about changing the main template used for the edit form. I can onl开发者_StackOverflow社区y add content to the page by filling slots. I tried changing the opening HTML tag without success:

<html xmlns="http://www.w3.org/1999/xhtml"

  xml:lang="en"

  lang="en"

  xmlns:tal="http://xml.zope.org/namespaces/tal"

  xmlns:metal="http://xml.zope.org/namespaces/metal"

  xmlns:i18n="http://xml.zope.org/namespaces/i18n"

  metal:use-macro="here/a_different_main_template/macros/master"

  i18n:domain="plone">

(where a_different_main_template is defined in my skin layer alongside my customised edit template)

Is there a new way to replace the main template used for a particular type such that the default edit view in particular will use it (I'm fine with overriding the "view" views, but don't want to recreate the Edit/Add forms, just use them within a new template)?


The usual approach would be to register an @@edit view for your type that uses your macro in its page template and making sure that's set as the target of the 'edit' method alias in the FTI (portal_types). You can obviously copy the standard base_edit.pt file as a starting point for your new view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜