[MGNLUI-4537] Define relationships between content types Created: 16/Apr/18  Updated: 29/Jan/19  Resolved: 09/Aug/18

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: None
Fix Version/s: 6.0

Type: Story Priority: Neutral
Reporter: Christopher Zimmermann Assignee: Oanh Thai Hoang
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: 0d
Time Spent: 4d 3.5h
Original Estimate: Not Specified

Attachments: PNG File generatedAppDefinition.png     PNG File generatedDetailSubApp.png     PNG File linkFieldData.png     PNG File referenceChooser.png    
Issue Links:
Problem/Incident
causes MGNLCT-61 Reference fields to CT-retrofitted ap... Closed
causes MGNLCT-76 Content type reference should be stor... Closed
causes MGNLCT-59 References to other CT should be expl... Closed
causes MGNLCT-93 Investigate ability to override model... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Release notes required:
Yes
Documentation update required:
Yes
Date of First Response:
Epic Link: Content types foundation
Sprint: Saigon 150, Saigon 151
Story Points: 8

 Description   

User story:

As a Business Analyst / Developer, I can define references between content types. It's common to link between content items, like blog posts link to authors.

A reference is a link to another content type. 

Acceptance criteria:

  • Developer can configure fields which act as references to items of other content types.
    • For example a "tour" can reference an "author" content type, or a story could reference multiple "events" in an event content type. 
    • A reference is like the current link field, except it links to another content-type.
  • Authors can then use the field to reference an item in the target content type via a chooser.
  • https://wiki.magnolia-cms.com/display/TH2/Content+Types+Stories#ContentTypesStories-Criteria


 Comments   
Comment by Christopher Zimmermann [ 24/Jul/18 ]

Something important to keep in mind here is that the reference should not be tied to JCR, just to the CT. This "Epic Criteria" item is relevant: https://wiki.magnolia-cms.com/display/TH2/Content+Types+Stories#ContentTypesStories-Criteria:Canworkwithanydatasource

Comment by Christopher Zimmermann [ 28/Aug/18 ]

Please describe how this feature works and/or provide an example - or link to a document that does.

Comment by Hieu Nguyen Duc [ 29/Aug/18 ]

This is how the implementation meets the acceptance criteria.

Referencing to other content type

Given these two content types

/content-type-examples/contentTypes/country.yaml

datasource:
  workspace: countries
model:
  properties:
    - name: countryName

/content-type-examples/contentTypes/tourist.yaml

datasource:
  workspace: tourists
model:
  properties:
    - name: country
      type: country

and these two apps

/content-type-examples/apps/countryApp.yaml

!with-type:country

/content-type-examples/apps/touristApp.yaml

!with-type:tourist

Then the generated detail subapp will show

LinkField references to "country" content type

App definition shows

Data are stored as

Reference:

Documentation is ongoing: https://documentation.magnolia-cms.com/display/DOCS57/Model+definition

Generated at Mon Feb 12 09:17:37 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.