Open texnixe opened 5 years ago
The same option would make sense for the files field and there is already an issue for the users field.
Maybe we should do it analog to checkboxes or select?
query:
fetch: page.files
value: "{{ file.autoid }}"
Yes, that would be best.
Something new about that?
Any update here? Feature would be much appreciated.
@jonasfeige You can give priority to the feature by upvoting.
I accidently added another issue for this topic just yesterday (see https://github.com/getkirby/ideas/issues/609).
TL;DR: Using just a value
property won’t work technically, as the picker also need a ways of efficently fetching the selected pages/files when displaying the field.
If the pages field e.g. uses AutoID or anything else but the full page ID, it would need to go through the entire site tree, evaluate the query defined in the field’s value
property for every single page (worst-case) to find the selected page(s). It would propably need a dedicated extension type or at least a callback function that can handle both getting the identifier or getting a page by identifier. For the files field however, this would be a bit easier, as the field just needs to check a page’s children. But nevertheless, this would be much easier on the backend to use a callback that can handle all the logic involved.
There are probably not so many options that really make sense to store when selecting something from a picker field, as one usually needs a unique identifier:
(Rough) Example:
# site/plugins/autoid/index.php
<?php
Kirby::plugin('my/plugin', [
'resolver' => [
'autoid' => function ($idOrModel, $parent = null) {
if (is_object($idOrModel)) {
// Object given, return its AutoID
return $idOrModel->AUTOID();
}
// string given, fetch page/file
return autoid($idOrModel);
},
],
]);
# site/blueprints/fields/page.yml
type: pages
label: Subpage
resolver: autoid
I'm looking for exactly this as I'm saving related pages of an article. If a pages' IDs or UIDs change often, it could become a maintenance nightmare. I'd love something like auto id / a UUID to be in Kirby's core.
@fabianmichael, does your rough example already work as you described it? Tried it, but no success, I might be doing something wrong, though. Thänx!
This would be useful when using the AutoID plugin to store unique references to a page. Currently, we have to use a select type of field to achieve this.