-
Notifications
You must be signed in to change notification settings - Fork 3
Symphony Relationships Proposal
Proposal by Tony Arnold [email protected]
Describe a method by which Symphony CMS sections can be formally associated with each other.
Assumptions:
-
Initially, self referential relationships will not be supported;
-
All relationships are one-way: parent → child/children (although children could potentially have children of their own);
-
Children can have multiple parents (although this should probably be configurable);
-
Relationships define the following attributes:
-
Minimum required children:
[0—9]+ (DEFAULT: 0)
-
Maximum required children:
[0—9]+ || NULL (DEFAULT: NULL)
-
Type:
AND || OR (DEFAULT: AND)
-
-
Setting any relationship to be required will enforce that the relationship’s minimum children >= 1;
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).
ENTRY 12 IN SECTION A {TextBox}
<field type="text" label="My Field" id="my-field" minimum-items="0" maximum-items="1" />
<myentry>
<my-field>Hi There!</my-field>
</myentry>
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.
ENTRY 54 IN SECTION A {TextBox}
ENTRY 5 IN SECTION A {TextBox}
ENTRY 2 IN SECTION A {TextBox}
<field type="text" label="My Field" id="my-field" minimum-items="0" maximum-items="unlimited" />
<myentry>
<my-field>Hi There!</my-field>
<my-field>And another.</my-field>
...
</myentry>
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.
ENTRY 1 IN SECTION A {TextBox, Author, Date}
ENTRY 15 IN SECTION B {TextBox, TextBox, Date}
ENTRY 225 IN SECTION A {TextBox, Author, Date}
ENTRY 1 IN SECTION B {TextBox, TextBox, Date}
ENTRY 7 IN SECTION B {TextBox, TextBox, Date}
<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>
<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>
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.
ENTRY 1 IN SECTION A {TextBox, Author, Date}
ENTRY 2 IN SECTION A {TextBox, Author, Date}
ENTRY 3 IN SECTION A {TextBox, Author, Date}
OR
ENTRY 3 IN SECTION B {TextBox, TextBox, Date}
ENTRY 6 IN SECTION B {TextBox, TextBox, Date}
ENTRY 2 IN SECTION B {TextBox, TextBox, Date}
<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>
<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>
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.
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.
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.
- Re-use (ie. multiple parents for a single child) — SSM does this currently, so we should allow the functionality?