Skip to content

Commit ef7c4f2

Browse files
committed
Clarify page create dialog docs, fixes #2194
1 parent d1accb0 commit ef7c4f2

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

content/docs/3_reference/3_panel/1_blueprints/0_page/reference-article.txt

+29-2
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,38 @@ The page create dialog also allows you to automatically generate title and/or sl
145145
create:
146146
title: "{{ page.location }} – {{ page.date.toDate('M Y') }}"
147147
slug: "{{ page.location.slug }}-{{ page.date.toDate('Y-m-d') }}"
148+
fields:
149+
- location
150+
- date
148151
```
149152

150-
Custom fields from the create dialog will be accessible as Kirby query starting with `page` (in this example the fields `location` and `date`). Moreover, you can also use queries to access information not specific to the page (through the `kirby` or `site` entry point).
153+
Note that the page fields you want to query within the string template need to be in the list of fields within the create option (in this example, `location` and `date`), and those fields need to be present in the page blueprint itself.
154+
155+
However, you can also query information not specific to the current page through the `kirby` or `site` entry points.
156+
157+
This means, you could, for example, create a custom site method that returns the current Unix timestamp, and use that in your string template:
151158

152-
If title and slug are generated automatically and no custom fields are defined for the page creation dialog, the dialog will be skipped and the page is created immediately.
159+
```yaml
160+
create:
161+
title: "{{ site.time }}"
162+
slug: "{{ site.time }}"
163+
```
164+
165+
And in a plugin, define the method
166+
167+
```php "/site/plugins/custom-methods/index.php"
168+
<?php
169+
170+
Kirby::plugin('getkirby/custom-methods', [
171+
'siteMethods' => [
172+
'time' => function() {
173+
return time();
174+
}
175+
]
176+
]);
177+
178+
```
179+
If title and slug are generated automatically, and no custom fields are defined for the page creation dialog, the dialog will be skipped and the page is created immediately.
153180
</since>
154181

155182
### Supported field types

0 commit comments

Comments
 (0)