Skip to content

Symphony Relationships Proposal

tonyarnold edited this page Oct 6, 2011 · 2 revisions

Symphony Relationships Proposal

Proposal by Tony Arnold [email protected]

Overview

Describe a method by which Symphony CMS sections can be formally associated with each other.

Approach

Assumptions:

  1. Initially, self referential relationships will not be supported;

  2. All relationships are one-way: parent → child/children (although children could potentially have children of their own);

  3. Children can have multiple parents (although this should probably be configurable);

  4. Relationships define the following attributes:

    1. Minimum required children: [0—9]+ (DEFAULT: 0)

    2. Maximum required children: [0—9]+ || NULL (DEFAULT: NULL)

    3. Type: AND || OR (DEFAULT: AND)

  5. Setting any relationship to be required will enforce that the relationship’s minimum children >= 1;

Relationship Types

Single Section Type

Simple, one-way relationship a single field linked to a single entry in a single section.

This is what the Select Box Link field currently provides functionally (with “Allow selection of multiple options” disabled).

Example

  1. ENTRY 12 IN SECTION A {TextBox}

Sample definition

<field type="text" label="My Field" id="my-field" minimum-items="0" maximum-items="1" />

Sample output

<myentry>
   <my-field>Hi There!</my-field>
</myentry>

Single Section Type Repeating

A simple one-way relationship that links a single field within an entry to multiple entries within another section, maintaining ordering.

This is what both the Sub Section Manager (SSM) and Select Box Link field (with “Allow selection of multiple options” enabled) provide currently. SSM implements a full user-interface for interacting with the data stored on the other side of the relationship.

Example

  1. ENTRY 54 IN SECTION A {TextBox}
  2. ENTRY 5 IN SECTION A {TextBox}
  3. ENTRY 2 IN SECTION A {TextBox}

Sample definition

<field type="text" label="My Field" id="my-field" minimum-items="0" maximum-items="unlimited" />

Sample output

<myentry>
   <my-field>Hi There!</my-field>
   <my-field>And another.</my-field>
   ...
</myentry>

Multiple Section Types Grouped Repeating (AND)

A complex one-way relationship that links a single field within an entry to multiple entries within multiple fields from a list of predefined sections, maintaining ordering.

This is what the Dynamic Text Grouping extension does currently.

Example

  1. ENTRY 1 IN SECTION A {TextBox, Author, Date}
  2. ENTRY 15 IN SECTION B {TextBox, TextBox, Date}
  3. ENTRY 225 IN SECTION A {TextBox, Author, Date}
  4. ENTRY 1 IN SECTION B {TextBox, TextBox, Date}
  5. ENTRY 7 IN SECTION B {TextBox, TextBox, Date}

Sample definition

<container minimum-items="0" maximum-items="unlimited" type="and" id="my-container">
   <field type="text" label="My Field" id="my-field"/>
   <field type="fileupload" label="My File" id="my-file"/>
</container>

Sample output

<myentry>
   <my-containers>
       <my-container>
           <my-field>Image One.</my-field>
           <my-file>/some/path/image1.jpg</my-file>
       </my-container>
       <my-container>
           <my-field>Image Two.</my-field>
           <my-file>/some/other/path/image2.jpg</my-file>
       </my-container>
   </my-containers>
   ...
</myentry>

Single Section Type Grouped Repeating (OR)

A complex one-way relationship that links a single field within an entry to multiple entries within a single field from a list of predefined sections, maintaining ordering.

No third-party extensions currently provide this functionality.

Example

  1. ENTRY 1 IN SECTION A {TextBox, Author, Date}
  2. ENTRY 2 IN SECTION A {TextBox, Author, Date}
  3. ENTRY 3 IN SECTION A {TextBox, Author, Date}

OR

  1. ENTRY 3 IN SECTION B {TextBox, TextBox, Date}
  2. ENTRY 6 IN SECTION B {TextBox, TextBox, Date}
  3. ENTRY 2 IN SECTION B {TextBox, TextBox, Date}

Sample definition

<container minimum-items="0" maximum-items="unlimited" type="or" id="my-container">
   <field type="text" label="My Field" id="my-field"/>
   <field type="fileupload" label="My File" id="my-file"/>
</container>

Sample output

<myentry>
   <my-container>
       <my-field>Image One.</my-field>
   </my-container>
   <my-container>
       <my-file>/some/other/path/image2.jpg</my-file>
   </my-container>
   ...
</myentry>

Implementation

The four scenarios documented in “Relationship Types” can be boiled down to two distinct implementations. Keep in mind that this document outlines the back end for relationships, and does not dictate a front end user interface.

The current release of Symphony allows “associations” between sections by specifying a field within one section as a parent, and a field within another section as a child. This limits the ability of fields to link to entries of more than one type of section from a single relationship.

The initial work for implementation would be around removing this limitation by making the relationship from a field within a section directly to another section, not to a field within that section. The child section would need to have a parent attribute added that would allow traversal from the child to the parent.

1 … 1 Section Type Relationship

The basic relationship between fields is where one field within a section links to multiple instances in a single other section. Single, one instance to another instance linking can be achieved by setting the maximum number of children allowed to 1.

1 … n Section Types Relationship

The more complex relationship is one where a single field can relate to multiple instances across a multitude of section types. This will require some form of generic bridging between sections be implemented.

To Do & Thought Food

  1. Re-use (ie. multiple parents for a single child) — SSM does this currently, so we should allow the functionality?
Clone this wiki locally