Display RelationList/RelationChoice Field in page template

I created a buildout with Python 3.6 and Plone 5.2.1.
I try to display the title and the link (URL) of a RelationList/RelationChoice which is on the content object in the folder. It should be displayed on the program_view, which is the container object of the track object.
The track object has the relations field 'room' which points to a room object (all Dexterity content types). The room objects are inside a room folder in the site root.

    room = RelationList(
        title=_(u'Choose the room for the track'),
        default=[],
        value_type=RelationChoice(vocabulary='ConferenceRoom'),
        required=False,
        missing_value=[],
    )
    directives.widget(
        'room',
        RadioFieldWidget,
    )

I tried to display the room title with:

<span tal:content="item/room/to_object/Title" />

But this ('to_object') seemed not to work anymore for relations.

Thanks for any hints.

As the name RelationList indicates, you will have a list of items and not a single item. So either it should be rooms or room should be a RelationChoice.

Using a different widget for RelatiobsChoice and RelationList ist not straightforward. The value of the vocabulary must be the object. See
https://training.plone.org/5/mastering-plone/relations.html#use-a-different-widget-for-relations.

Rendering relations was added in plone.app.z3cform 3.2.0 (see https://github.com/plone/plone.app.z3cform/pull/111). It is also discussed in https://training.plone.org/5/mastering-plone/relations.html#accessing-and-displaying-related-items.

I would consider rendering it without a widget

should be something like

<tal:loop tal:repeat="room item/room">
    ${room/to_object/Title}
</tal:loop>

Thanks for your hint. It would be great, if I could use a RelationChoice only. But I tried this and I couldn't connect inside the edit form to the related item(s) (room(s)). There were no matching items found (although I tried to manually navigate to the room). The rooms are inside a folder 'rooms' in the Plone site root.

Thanks Philip. I already found the training material (you and others created). But I had to reread it carefully again and got (together with the hint from Andreas) a step further on my Plone education ladder :wink:
I could find a solution for the issue with the hint from Espen.
Thus one step further in my work on the Plone add-on :slight_smile:

Thaks Espen. That did it.
Another issue solved :slight_smile:

This will not do a check if the user has the permission to view the related object. I suggest you update to plone.app.z3cform 3.2.0 and use from plone.dexterity.browser.view import DefaultView as a base-class and <div tal:content="structure view/w/room/render" /> to render relations.

Thanks Philip for your hint.

Plone Foundation Code of Conduct