1

I have a Dexterity-based content type with the IRelatedItems behavior enabled using:

<property name="behaviors">
  <element value="plone.app.relationfield.behavior.IRelatedItems" />
</property>

I want to render the list of related items on my template but I don't know how to do it.

Any hints?

hvelarde
  • 2,875
  • 14
  • 34

3 Answers3

4

Found it: first the custom view has to be a display form, so it must derive from plone.directives.dexterity.DisplayForm:

class MyCustomView(dexterity.DisplayForm):
    grok.context(IMyContentType)
    grok.require('zope2.View')

Then you can use something like this on your page template:

<fieldset id="related-items" tal:condition="context/relatedItems">
    <legend i18n:translate="">Related items</legend>
    <tal:relateditems tal:content="structure view/w/IRelatedItems.relatedItems/render" />
</fieldset>
hvelarde
  • 2,875
  • 14
  • 34
3

Isn't this what you are looking for?

gforcada
  • 2,498
  • 17
  • 26
  • Almost; the documentation is not updated and it doesn't explain how to use the widget in a template. – hvelarde Aug 04 '11 at 00:06
  • You would better have summarized the contents of your link (as per StackOverflow 'styleguide'). Like many other plone.org-links, this one is dead. – onse Oct 29 '13 at 11:09
2

You could consider using the standard dexterity relation behaviour:

plone.app.dexterity.related.IRelatedItems

With this behaviour, related items automatically appear in the content's standard view.

Giacomo

Giacomo Spettoli
  • 4,476
  • 1
  • 16
  • 24
  • 2
    That behavior is deprecated in plone.app.dexterity since v1.0.1; you have to use the one in plone.app.relationfield. Also I need to use my own view, not the standard one. – hvelarde Aug 04 '11 at 00:04