Skip to content

Commit 724136f

Browse files
stevepiercypbauer
authored andcommitted
Add heading labels and meta data
1 parent b3bb0d1 commit 724136f

File tree

1 file changed

+51
-7
lines changed

1 file changed

+51
-7
lines changed

docs/backend/relations.md

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
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"
77
---
88

9+
(relations-label)=
10+
911
# Relations
1012

1113
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
1416

1517
By using custom relations you can model your data in a much more meaningful way.
1618

19+
20+
(relations-creating-and-configuring-relations-in-a-schema-label)=
21+
1722
## Creating and configuring relations in a schema
1823

1924
Relate to one item only.
@@ -51,7 +56,10 @@ minions = RelationList(
5156

5257
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.
5358

54-
### Controlling what to relate to
59+
60+
(relations-controlling-relation-targets-label)=
61+
62+
### Controlling relation targets
5563

5664
The best way to control wich item should be relatable to is to configure the widget with `directives.widget()`.
5765
In the following example you can only relate to Documents:
@@ -76,7 +84,10 @@ directives.widget(
7684
)
7785
```
7886

79-
### Configure the RelatedItemsFieldWidget
87+
88+
(relations-configure-the-relateditemsfieldwidget-label)=
89+
90+
### Configure the `RelatedItemsFieldWidget`
8091

8192
```{note}
8293
These settings only have a effect in Plone 6 Classic.
@@ -129,6 +140,9 @@ directives.widget(
129140
)
130141
```
131142

143+
144+
(relations-using-the-search-mode-of-the-related-items-widget-label)=
145+
132146
### Using the search mode of the Related Items Widget
133147

134148
```{note}
@@ -181,6 +195,9 @@ directives.widget(
181195
Search mode of RelationWidget
182196
```
183197

198+
199+
(relations-define-favorite-locations-label)=
200+
184201
### Define Favorite Locations
185202

186203
The `RelatedItemsFieldWidget` allows you to set favorites:
@@ -255,6 +272,9 @@ class IHaveMinions(model.Schema):
255272
)
256273
```
257274

275+
276+
(relations-relationfields-through-the-web-or-in-xml-label)=
277+
258278
## RelationFields through the web or in xml
259279

260280
It is surprisingly easy to create RelationFields through the web.
@@ -295,6 +315,9 @@ RelationList:
295315
</field>
296316
```
297317

318+
319+
(relations-using-different-widgets-for-relations-label)=
320+
298321
## Using different widgets for relations
299322

300323
```{todo}
@@ -371,6 +394,8 @@ directives.widget(
371394
Relationlist Field with AJAXSelect
372395

373396

397+
(relations-accessing-and-displaying-related-items-label)=
398+
374399
## Accessing and displaying related items
375400

376401
To display related items you can use the render method of the default widget e.g.:
@@ -403,6 +428,9 @@ class EvilMastermindView(BrowserView):
403428

404429
This returns the related items so that you will able to render them anyhow you like.
405430

431+
432+
(relations-inspecting-relations-label)=
433+
406434
## Inspecting relations
407435

408436
You Plone 6 Classic you can inspect all relations and backrelations in your site using the control panel `/@@inspect-relations`.
@@ -416,8 +444,13 @@ The relations controlpanel
416444
In Plone 5 this is available through the addon [collective.relationhelpers](https://pypi.org/project/collective.relationhelpers).
417445

418446

447+
(relations-programming-with-relations-label)=
448+
419449
## Programming with relations
420450

451+
452+
(relations-programming-with-relations-plone-6-label)=
453+
421454
### Plone 6
422455

423456
Since Plone 6 `plone.api` has methods to create, read, and delete relations and backrelations.
@@ -454,16 +487,22 @@ api.relation.delete(source=portal["bob"])
454487
See the chapter {ref}`plone:chapter-relation` of the docs for `plone.api` for more details.
455488

456489

490+
(relations-programming-with-relations-plone-5.2-and-older-label)=
491+
457492
### Plone 5.2 and older
458493

459494
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.
460495

461496

462-
### Restapi
497+
(relations-programming-with-relations-rest-api-label)=
498+
499+
### REST API
463500

464501
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
465502

466503

504+
(relations-relationfields-without-relations-label)=
505+
467506
## Relationfields without relations
468507

469508
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(
516555
For control panels this is the best way to store relations since you cannot store `RelationValue` objects in the registry.
517556
```
518557

558+
(relations-the-stack-label)=
559+
519560
## The stack
520561

521562
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
563604

564605
The built-in linkintegrity feature of Plone 5 is also implemented using relations.
565606

607+
608+
(relations-relationvalues-label)=
609+
566610
### RelationValues
567611

568612
RelationValue objects have a fairly complete API.

0 commit comments

Comments
 (0)