Skip to content

Commit 905111d

Browse files
committed
Add tip about nested page hierarchies in CTB documentation
1 parent 64f7011 commit 905111d

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
@@ -20373,6 +20373,33 @@ export default ({ env }) => ({
2037320373

2037420374

2037520375

20376+
# Content-type Builder
20377+
Source: https://docs.strapi.io/cms/features/content-type-builder
20378+
20379+
## Relation
20380+
Description: Example
20381+
(Source: https://docs.strapi.io/cms/features/content-type-builder#relation)
20382+
20383+
Language: JSON
20384+
File path: Populate
20385+
20386+
```json
20387+
{
20388+
populate: {
20389+
children: {
20390+
fields: ['title', 'slug'],
20391+
populate: {
20392+
children: {
20393+
fields: ['title', 'slug'],
20394+
},
20395+
},
20396+
},
20397+
},
20398+
}
20399+
```
20400+
20401+
20402+
2037620403
# Custom Fields
2037720404
Source: https://docs.strapi.io/cms/features/custom-fields
2037820405

docusaurus/static/llms-full.txt

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

80528052
</Tabs>
80538053

8054+
:::tip Modeling nested page hierarchies
8055+
To model a navigable tree of pages:
8056+
1. Add a `Page` collection type with a "Slug" (UID) and (optionally) an "Order" (Integer) field to control sibling ordering.
8057+
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.
8058+
3. When reading data, populate `children` recursively to load the tree. Keep the recursion depth small to avoid large responses.
8059+
8060+
<details>
8061+
<summary>Example</summary>
8062+
```json title="Populate nested children for a page tree"
8063+
{
8064+
populate: {
8065+
children: {
8066+
fields: ['title', 'slug'],
8067+
populate: {
8068+
children: {
8069+
fields: ['title', 'slug'],
8070+
},
8071+
},
8072+
},
8073+
},
8074+
}
8075+
```
8076+
</details>
8077+
8078+
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)).
8079+
:::
8080+
80548081
#### <img width="28" src="/img/assets/icons/v5/ctb_boolean.svg" /> Boolean {#boolean}
80558082

80568083
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)