Is it possible to access images of multiple pages via a files field?
I want to select images out of site and page.
Like this:
introImg1:
type: files
query: site.images + page.images
Is it possible to access images of multiple pages via a files field?
I want to select images out of site and page.
Like this:
introImg1:
type: files
query: site.images + page.images
You can define a collection and then query the collection.
Edit: However, come to think of it, I think you can’t access the current page, so using a page model will be better in this case.
Thanks. You are right a collection doesn’t work. I will check the page model later, maybe I will find a solution there.
Trying to do the same thing. Want to query images from ‘site’ as well as from the current page
Use a page model or maybe even better a page method (because you probably want to do this on all types of pages) and merge the files.
Kirby::plugin('my/page-methods', [
'pageMethods' => [
'getAllFiles' => function () {
$siteFiles = site()->files();
return $siteFiles->add($this->files());
}
]
]);
Blueprint
fields:
files:
type: files
query: page.getAllFiles
Amazing, works great! Thanks so much!
I just tried:
query: page.files.add(site.files)
And it worked. Maybe something new?
I think the query language parser made steps forward in 3.2. Prior to that you couldn’t pass “subqueries” as arguments to function calls in queries. “site.files” would have simply been converted to a string or the whole query would have failed (one of those, not sure).