I would like to use this pages dialog (<k-pages-dialog/>
) in a plugin to select a page:
Looking at other uses of this component, I seemingly need to define some kind of endpoints for it to work. Just using this.$refs['pagesDialog'].open()
doesn’t work obviously. But how do I define these endpoints? And what does the pages dialog component expect? After looking at the source code and other plugins I can’t find anything useful.
Here’s the repository of my plugin with the recent pages dialog commit: https://github.com/medienbaecker/kirby-link-field
The endpoints relate to api endpoint created by your field.
Have a look at the original pages field.
If you define a pattern like 'pattern' => 'test'
for example you would be able to make request to the endpoint with something like this:
methods: {
test(data) {
return this.$api
.post(this.endpoints.field + '/test', data)
.then(response => {
//
});
}
}
I think you should be good to go if you just copy the api
part from the pages field. If you keep the /get-pages
endpoint you would of course need to change the pattern
accordingly.
Thanks a lot for your help, Lukas!
I had to additionally borrow the pageResponse
method from the pages field, and now it works!