Skip to content

Commit 1bb2bd2

Browse files
Add tip about nested page hierarchies in CTB documentation (#2876)
1 parent 859312a commit 1bb2bd2

File tree

3 files changed

+81
-0
lines changed

3 files changed

+81
-0
lines changed

docusaurus/docs/cms/features/content-type-builder.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,33 @@ Configuring the basic settings of the Relation field consists in choosing with w
481481

482482
</Tabs>
483483

484+
:::tip Modeling nested page hierarchies
485+
To model a navigable tree of pages:
486+
1. Add a `Page` collection type with a "Slug" (UID) and (optionally) an "Order" (Integer) field to control sibling ordering.
487+
2. Create a Relation field from `Page` to `Page` and choose *Many-to-one* so each page can set its "Parent page". Strapi automatically provides the inverse "Children pages" relation.
488+
3. When reading data, populate `children` recursively to load the tree. Keep the recursion depth small to avoid large responses.
489+
490+
<details>
491+
<summary>Example</summary>
492+
```json title="Populate nested children for a page tree"
493+
{
494+
populate: {
495+
children: {
496+
fields: ['title', 'slug'],
497+
populate: {
498+
children: {
499+
fields: ['title', 'slug'],
500+
},
501+
},
502+
},
503+
},
504+
}
505+
```
506+
</details>
507+
508+
The same populate pattern works with GraphQL or the Document Service API (see [Understanding populate guide](/cms/api/rest/guides/understanding-populate#populate-several-levels-deep-for-specific-relations)).
509+
:::
510+
484511
#### <img width="28" src="/img/assets/icons/v5/ctb_boolean.svg" /> Boolean {#boolean}
485512

486513
The Boolean field displays a toggle button to manage boolean values (e.g. Yes or No, 1 or 0, True or False).

docusaurus/static/llms-code.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20616,6 +20616,33 @@ export default ({ env }) => ({
2061620616

2061720617

2061820618

20619+
# Content-type Builder
20620+
Source: https://docs.strapi.io/cms/features/content-type-builder
20621+
20622+
## Relation
20623+
Description: Example
20624+
(Source: https://docs.strapi.io/cms/features/content-type-builder#relation)
20625+
20626+
Language: JSON
20627+
File path: Populate
20628+
20629+
```json
20630+
{
20631+
populate: {
20632+
children: {
20633+
fields: ['title', 'slug'],
20634+
populate: {
20635+
children: {
20636+
fields: ['title', 'slug'],
20637+
},
20638+
},
20639+
},
20640+
},
20641+
}
20642+
```
20643+
20644+
20645+
2061920646
# Custom Fields
2062020647
Source: https://docs.strapi.io/cms/features/custom-fields
2062120648

docusaurus/static/llms-full.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8114,6 +8114,33 @@ Relations where at least one side can reference several entries are called multi
81148114

81158115
</Tabs>
81168116

8117+
:::tip Modeling nested page hierarchies
8118+
To model a navigable tree of pages:
8119+
1. Add a `Page` collection type with a "Slug" (UID) and (optionally) an "Order" (Integer) field to control sibling ordering.
8120+
2. Create a Relation field from `Page` to `Page` and choose *Many-to-one* so each page can set its "Parent page". Strapi automatically provides the inverse "Children pages" relation.
8121+
3. When reading data, populate `children` recursively to load the tree. Keep the recursion depth small to avoid large responses.
8122+
8123+
<details>
8124+
<summary>Example</summary>
8125+
```json title="Populate nested children for a page tree"
8126+
{
8127+
populate: {
8128+
children: {
8129+
fields: ['title', 'slug'],
8130+
populate: {
8131+
children: {
8132+
fields: ['title', 'slug'],
8133+
},
8134+
},
8135+
},
8136+
},
8137+
}
8138+
```
8139+
</details>
8140+
8141+
The same populate pattern works with GraphQL or the Document Service API (see [Understanding populate guide](/cms/api/rest/guides/understanding-populate#populate-several-levels-deep-for-specific-relations)).
8142+
:::
8143+
81178144
#### <img width="28" src="/img/assets/icons/v5/ctb_boolean.svg" /> Boolean {#boolean}
81188145

81198146
The Boolean field displays a toggle button to manage boolean values (e.g. Yes or No, 1 or 0, True or False).

0 commit comments

Comments
 (0)