Query result error with Pages Display Section

Hello, @texnixe I am using your Pages Display Section plugin.

I have a project.php model with:

<?php

class ProjectPage extends Page
{

    public function getResources()
    {
        return site()->index()->filterBy('intendedTemplate', 'resource')->filter(fn ($resource) => $resource->project()->toPages()->has($this));
    }

}

a project.yml blueprint with:

title: Project
options:

tabs:
  # content tab
  content:
    label: Content
    icon: text
    columns:

        - width: 4/4
          sections:

            resource:
              headline: Related resources
              type: pagesdisplay
              query: page.getResources
              image: page.cover.toFile

On this page in the panel, instead of displaying the “Resource” section, I get this error:

The section "resource" could not be loaded: Query result must be of type "Kirby\Cms\Pages", "Kirby\Cms\Field" given

And a resource.yml blueprint with:

title: Resource
tabs:
  # content tab
  content:
    label: Content
    icon: text
    columns:

        - width: 2/4
          sections:

            leftContents:
              type: fields
              fields:

                project:
                  label: Related Projects
                  type: pages
                  query: site.children.template('projects').children.template('project')
                  help: This field allows for the selection of up to two related projects.
                  layout: cardlets
                  image: page.cover.toFile

I have used a similar set up on other sites, but I am not sure what I am doing wrong here. :face_with_diagonal_mouth:

Hm, even though this is not my plugin, I think the query in combination with the model should work.

Make sure you actually saved your models and that it’s in the /site/models folder. For some reason, the method is not found and getResources() therefore treated as a field method.

Whoops, my mistake!

Thanks for your assistance, you were right, I an error in my folder set up.