Blueprint - Query other pages using current page uid

Hi there,

I’m pretty new at Kirby but having a lot of fun playing with it. Really nice coding philosophy but it sometimes a bit hard to find the appropriate documentation :slight_smile:

I have two pages type : News and Artists. I would select in my Artist blueprint the News pages wich contains the artist field with the current uid.

I did that :

  news:
                name: News 2
                fields:
                  article:
                    type: pages
                    info: "{{ page.date.toDate('d.m.Y') }}"
                    query: site.children.template('news').filterBy('artist', {{ uid }})

What should be the right syntax ?

Thanks a lot and have a good day !

Has this been solved by the answer on Discord? Please try not to double post (and least not without reference to the original topic).

Hi,

thanks that was a good advice, and found a way to solve my problem. Here is what I did :

Kirby::plugin('my/page-methods', [
    'pageMethods' => [
        'artistNews' => function ($site) {

            $news = $site->children()->template('news')->published();

            $selection = $news->filter(function ($child) {
              return $child
                     ->artist()
                     ->toPages()
                     ->filterBy('uid', $this->uid())
                     ->isNotEmpty();
            });

            return $selection;
        }
    ]
]);

It works perfectly.

Thanks for the help, and sorry for the doublon with Discord. I’ll watch this out in the future.