You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/backend/relations.md
+51-7Lines changed: 51 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,13 @@
1
1
---
2
2
html_meta:
3
-
"description": ""
4
-
"property=og:description": ""
5
-
"property=og:title": ""
6
-
"keywords": ""
3
+
"description": "Relations allow developers to model relationships between objects without using links or a hierarchy."
4
+
"property=og:description": "Relations allow developers to model relationships between objects without using links or a hierarchy."
5
+
"property=og:title": "Relations"
6
+
"keywords": "Relations"
7
7
---
8
8
9
+
(relations-label)=
10
+
9
11
# Relations
10
12
11
13
You can model relationships between content items by placing them in a hierarchy (e.g. a folder _speakers_ containing the (folderish) speakers and within each speaker the talks) or by linking them to each other in Richtext fields. But where would you then store a talk that two speakers give together?
@@ -14,6 +16,9 @@ Relations allow developers to model relationships between objects without using
14
16
15
17
By using custom relations you can model your data in a much more meaningful way.
We can see that the [code for the behavior IRelatedItems](https://github.com/plone/plone.app.relationfield/blob/master/plone/app/relationfield/behavior.py) does exactly the same.
53
58
54
-
### Controlling what to relate to
59
+
60
+
(relations-controlling-relation-targets-label)=
61
+
62
+
### Controlling relation targets
55
63
56
64
The best way to control wich item should be relatable to is to configure the widget with `directives.widget()`.
57
65
In the following example you can only relate to Documents:
In older Plone-Versions you can use [collective.relationhelpers](https://pypi.org/project/collective.relationhelpers) to create and read relations and backrelations in a very similar way.
A restapi endpoint to create, read, and delete relations and backrelations will be part of `plone.restapi`. See https://github.com/plone/plone.restapi/issues/1432
A light-weight alternative to using relations is to store a UUID of the object you want to link to. Obviously you will loose the option to query the relation-catalog for these but you could create a custom index for that purpose.
@@ -516,6 +555,8 @@ directives.widget(
516
555
For control panels this is the best way to store relations since you cannot store `RelationValue` objects in the registry.
517
556
```
518
557
558
+
(relations-the-stack-label)=
559
+
519
560
## The stack
520
561
521
562
Relations are based on [zc.relation](https://pypi.org/project/zc.relation/).
@@ -563,6 +604,9 @@ The simplest concrete advantage is the possibility to see what links to your obj
563
604
564
605
The built-in linkintegrity feature of Plone 5 is also implemented using relations.
0 commit comments