rasteiner / k3-pagesdisplay-section

K3 plugin: display any page list in a section. Any parent, many parents, filtered, don't care.
Other
45 stars 8 forks source link

Add possibility to use Kirby collections #1

Closed tristantbg closed 4 years ago

tristantbg commented 4 years ago

When I try to do this : kirby.collection("projects")

I get this error : The section "projects" could not be loaded: Invalid query result - Result must be of type Kirby\Cms\Pages, NULL given.

I used site.index instead but it is quite bad for performance: https://getkirby.com/docs/reference/objects/site/index#details

Thank you.

rasteiner commented 4 years ago

Hello, sorry for the long wait.

You could probably hack this into the plugin by changing this line: https://github.com/rasteiner/k3-pagesdisplay-section/blob/master/src/PagesDisplaySection.php#L29

from

if(is_a($pages, 'Kirby\\Cms\\Pages')) {

to

if(is_a($pages, 'Kirby\\Cms\\Collection')) {

I'm not 100% sure I want to do this for everyone, since collections could really contain anything. But I guess that could also be the users responsibility to give the plugin only collections of actually pages

rasteiner commented 4 years ago

Discard what I've said above. Collections don't work that way and the problem was elsewhere.

I'll add the feature and let you know.

rasteiner commented 4 years ago

collections via kirby.collection('name') should now work in version 0.0.6

tristantbg commented 4 years ago

Great! Thanks.