IPublishTraverse subgraph - without 'view'

Hi all,

Is it possible to remove '@@my_view' or variants thereof from an URL when using a BrowserView which implements IPublishTraverse?

I have studied https://docs.plone.org/develop/plone/serving/traversing.html#custom-traversal
and the questions/examples given in the forum (1, 2, 3 )
as well as a blog post by @jensens which got me to my current result

/Plone/category/view/foo/bar/baz
['foo', 'bar', 'baz']

If not, it there an alternate approach? Argh! Just now, I see...

Looks like this feature is often sought after, is there a definitive answer?

-Norbert

I basically had the same issue with xmldirector.plonecore and xmldirector.connector and I also could not find a working solution.

For Dexterity content types I was able to achieve that by registering an adapter to zope.publisher.interfaces.browser.IBrowserRequest, overriding the default adapter plone.dexterity.browser.traversal.DexterityPublishTraverse.

In traversal.py:

from plone.dexterity.browser.traversal import DexterityPublishTraverse
from zope.component import adapter
from zope.publisher.interfaces.browser import IBrowserRequest

@adapter(IMyContentType, IBrowserRequest)
class MyContentTypePublishTraverse(DexterityPublishTraverse):

    def publishTraverse(self, request, name):
        u"""Override `FSConnectorPublishTraverse`."""
        try:
            return DexterityPublishTraverse.publishTraverse(self, request, name)
        except AttributeError:
            # Do your thing here.

And in configure.zcml:

<adapter factory=".traversal.MyContentTypePublishTraverse" />
2 Likes

Thank you! I had settled on two BrowserViews with the generic names "start" and "item" - resulting in search results and product view URLs such as:

https://example.com/en/products/outdoors/start/16
https://example.com/en/products/outdoors/item/someproduct

Will try your approach!

Thank you @rafaelbco Can't wrap my head around the mechanics yet, but your approach got me the result I was after. :star_struck:

plone-traversable-content

1 Like