Is it possible to override the template in the CMF skin using the Zope 3: page browser?

I am trying to override the view provided by the CMF skin layer <browser:page ...with the same attribute name=. Is it possible in Plone or browser views override other browser types?

+3
source share
3 answers

(It's a little late, but what the hell)

CMF layer fields override browser views. That is why you should prefix the @@browser name in the URL, i.e. eliminate it and make sure that the browser is being viewed instead of the CMF skin template.

In short, if you put @@forward, the browser will be overridden, otherwise not.

i.e:

localhost:8080/Plone/@@myview 

:

localhost:8080/Plone/myview

, - CMF tal:define View, @@myview. BrowserViews - CMF.

+5

CMF portal_skins . , IPublishTraverse. , ( Plone 3 - 100%, Plone 4):

from zope.component import adapts, queryMultiAdapter
from zope.publisher.interfaces.browser import IBrowserRequest 

from Acquisition import aq_base
from ZPublisher.BaseRequest import DefaultPublishTraverse
from Products.CMFCore.Skinnable import SKINDATA, SkinnableObjectManager

from thread import get_ident

_MARKER = object()

class SkinnableTraverser(DefaultPublishTraverse):
    adapts(SkinnableObjectManager, IBrowserRequest)

    def publishTraverse(self, request, name):
        """Let the default traverser do its job, but if the thing that was
        returned was from a skin layer and there a view with
        the same name, let the view win.
        """

        gotten = super(SkinnableTraverser, self).publishTraverse(request, name) 

        if not name.startswith('_') and not name.startswith('aq_'):
            sd = SKINDATA.get(get_ident())
            if sd is not None:
                ob, skinname, ignore, resolve = sd
                if resolve.get(name, None) is aq_base(gotten):
                    # This was retrieved as a skin resource
                    # Check if it could've been a view also

                    view = queryMultiAdapter((self.context, request), name=name)
                    if view is not None:
                        return view.__of__(self.context)

        return gotten

<adapter factory=".skins.SkinnableTraverser" />

, overrides.zcml. , . browserlayer.xml.

Martin

+3

, , , - "" plone_skins.

You can also try the “Alternative” method from http://plone.org/documentation/kb/applying-a-custom-view-to-a-specific-folder

+2
source

Source: https://habr.com/ru/post/1780226/


All Articles