-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docs/beta-features/widget-variable-types
- Loading branch information
Showing
3 changed files
with
65 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: Dynamic Default Values | ||
group: Fields | ||
weight: 30 | ||
--- | ||
|
||
When linking to `/admin/#/collections/posts/new` you can pass URL parameters to pre-populate an entry. | ||
|
||
For example given the configuration: | ||
|
||
```yaml | ||
collections: | ||
- name: posts | ||
label: Posts | ||
folder: content/posts | ||
create: true | ||
fields: | ||
- label: Title | ||
name: title | ||
widget: string | ||
- label: Object | ||
name: object | ||
widget: object | ||
fields: | ||
- label: Title | ||
name: title | ||
widget: string | ||
- label: body | ||
name: body | ||
widget: markdown | ||
``` | ||
clicking the following link: `/#/collections/posts/new?title=first&object.title=second&body=%23%20content` | ||
|
||
will open the editor for a new post with the `title` field populated with `first`, the nested `object.title` field | ||
with `second` and the markdown `body` field with `# content`. | ||
|
||
**Note:** URL Encoding might be required for certain values (e.g. in the previous example the value for `body` is URL encoded). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- | ||
title: Registering to CMS Events | ||
weight: 80 | ||
group: Customization | ||
--- | ||
|
||
You can execute a function when a specific CMS event occurs. | ||
|
||
Example usage: | ||
|
||
```javascript | ||
CMS.registerEventListener({ | ||
name: 'prePublish', | ||
handler: ({ author, entry }) => console.log(JSON.stringify({ author, data: entry.get('data') })), | ||
}); | ||
``` | ||
|
||
Supported events are `prePublish`, `postPublish`, `preUnpublish`, `postUnpublish`, `preSave` and `postSave`. The `preSave` hook can be used to modify the entry data like so: | ||
|
||
```javascript | ||
CMS.registerEventListener({ | ||
name: 'preSave', | ||
handler: ({ entry }) => { | ||
return entry.get('data').set('title', 'new title'); | ||
}, | ||
}); | ||
``` |