Use the Relationship-TypeΒΆ

Now the Person part descriptor can be updated to use the Person relationship type.

<part-component>
  <display-name>Person</display-name>
  <config>
    <input type="Relationship" name="person">
      <label>Person</label>
      <immutable>false</immutable>
      <indexed>false</indexed>
      <occurrences minimum="1" maximum="1"/>
      <config>
        <relationship-type>related-person</relationship-type>
      </config>
    </input>
  </config>
</part-component>

Once this is done, you will be able to choose a Person content for the part in the admin console. But the controller needs some updating to make it work dynamically. The following example shows how to get the related-person of the content.

/*
There are two ways to get content. This way only works when a page
with this `part` supports the content type. Then a URL that leads to
any `Person` content will reach this page and the content is
retrievable with `portal.getContent`. You can see this in action when
you click on a `Person` content in the admin console and it is
previewed in the page.
*/
var content = execute('portal.getContent');

// Find the related person id
var personId = component.config['person'];

// Fetch the actual person content
var person = execute('content.get', {
  key: personId
});