I'm hoping someone can point me to a Plone 5 example of a custom view that displays "Related content"

I'm struggling with getting this.
Thank you very much in advance.

There is one built in... it's displayed if you have set any "related content" when editing the item's Dublin Core metadata.

This functionality is build-in and out-of-the-box available with the default view of a content-types.

If you need a special view - for whatever reason - then you need write your own code with a browser view registered for a content-type.


Thank you both for your swift replies. !!!!

Is that what you were looking for, and do you know how to use it? (I'm not sure it's actually documented here https://docs.plone.org/working-with-content/index.html)

In Plone 3 i just hacked the view for backReferences, but there was already functionality i could call in the view via an existing getBRefs function. I was bouncing back and forth on whether or not to use referencelist/ referencechoice fields, but i figured i'd keep it simple /w just the dublin core functionality that stated. i found that the viewlet document_relateditems..pt has the functionality i need (and is what' in the default view) but i'm basically stuck there. i tried to borrow that code but to no avail.

As you probably know: Plone 3 is quite old, so you might want to upgrade your site.

Anyway: First thing no note is that most documentation will describe how to do this in Plone 4 and 5, so be sure that the docs you read are 'old'.

When it comes to views: The 'related items' is a viewlet that will display (below) your view if you make your view 'the correct way.

The correct way means to 'use a fill slot'

Have you managed to make a custom view 'without' the related items ?

It should look something like this (I think):

<html xmlns="http://www.w3.org/1999/xhtml"
    <metal:slot metal:fill-slot="content-core">
        <h1 tal:content="context/Title" />
          … etc

If you show your code here it might help.

Yes :slight_smile: that's what i'm doing. I can create a custom view without pain.
in plone 3: i simply used the following...

Using Plone 5.08 also btw.

 tal:referencedBy tal:define="backRefs here/getBRefs">
            <fieldset id="backReferences" tal:condition="backRefs">
                <tal:backRef repeat="item backRefs"
                                     define="use_view_action site_properties/typesUseViewActionInListings|python:();">
                    <p tal:define=" desc        item/Description;
              item_name     item/pretty_title_or_id;
              item_fieldtype      item/type;
                              item_type     item/portal_type;
                            item_url           item/absolute_url">
                    <span> <!--- OLD MARKED tal:attributes="class item_type_class">-->
                        <a href="" class=""
                            tal:attributes="href  item_url;
                                            title item/Description">
                            Related Item

(Sorry, had a hard time w/ this window rendering my code)
Where i just used he existing getBRefs function. i found (what i felt with my perennial newbie mind :slight_smile: ) that document_relateditems.pt has the magic i need.., but i can't get it to render.
(replacing view with context and domain with my product name ( guess) etc.)
I feel like i just have to "steal a viewlet " or it's code. i believe the block that covers " Categorization" but i am having problems.

i believe that the built in dublin core relation capability doesn't yield a Path or URL for the reference using just the behavior.

here 's the two references that i can get to via debug...

for i in item.dict['relatedItems']:print i
<z3c.relationfield.relation.RelationValue object at 0x7ff209203668>
<z3c.relationfield.relation.RelationValue object at 0x7ff2092036e0>

for i in item.dict['relatedItems']:print i.dict
{'to_id': 172458050, '_from_id': 172458049, 'from_attribute': 'relatedItems', 'parent': }
{'to_id': 172458051, '_from_id': 172458049, 'from_attribute': 'relatedItems', 'parent': }

below is what i thought i could use in document_relatedItems

 indent preformatted text by 4 spaces

<div class="relatedItems"
 tal:define="related view/related_items"
<div class="visualClear" id="clear-space-before-relatedItemBox"><!-- --></div>
<div id="relatedItemBox"
          tal:define="plone_view nocall:context/@@plone;
                      plone_layout nocall:context/@@plone_layout;
                      normalizeString nocall:plone_view/normalizeString;
                      context_state nocall:context/@@plone_context_state;
                      use_view_action python:context.portal_registry.get('types_use_view_action_in_listings', []);">
    <header i18n:translate="label_related_items">Related content</header>
      <li tal:repeat="item related">
        <span tal:define="desc                item/Description;
                          item_type           item/portal_type;
                          item_type_class     python:'contenttype-' + normalizeString(item_type);
                          item_wf_state       item/review_state|python: context_state.workflow_state();
                          item_wf_state_class python: 'state-' + normalizeString(item_wf_state);
                          item_url            item/getURL|item/absolute_url;
                          item_url            python:(item_type in use_view_action) and item_url+'/view' or item_url;
                          item_has_image      python:item.getIcon"
                          tal:attributes="title item_type">
          <a tal:attributes="href  item_url">
             <img class="image-icon"
                  tal:define="getIcon python:item.getURL() +'/@@images/image/icon'"
                  tal:attributes="src  string:$getIcon">
              <span tal:attributes="class string:$item_type_class $item_wf_state_class url;"
                      Item Title</span>
              <span class="discreet"



FYI: I Just found referenceable.rst in plone.app.referenceablebehavior. I'm hoping that will yield results shortly.