(I couldn’t find a proper answer in the forum, so I just ask.)
For a little event website I want to build with Kirby, I plan to have quite a number of different content types (= page templates), e.g. rooms, speakers, talk details (e.g. abstracts), talk schedules, topic categories, etc. All of those things are interconnected. For example, a talk can be held several times (= several linked talk schedules) and can have one or more speakers. The respective room, in turn, may not be directly linked to the talk, but must be linked to the talk schedule. (Because, for organizational reasons, a talk may be held twice, but not necessarily twice in the same room).
Having different page templates for all of these content types has the nice effect that I automatically have separate pages for each room, speaker, topic category, etc. – which I can use to display cumulated information in the frontend (e.g. all talks held by a certain speaker).
All these connections can be achieved with pages select fields in the panel. This is simple. But is there a way to at least see such connections in the panel when editing the linked page, too? Example: On page A there is a pages select field with page B selected. On page B (in the panel) this connection is not visible in any way by default.
Since I don’t want to fuss around with bidirectional editable connections using hooks, displaying “incoming” connections in the panel view of a certain page and being able to click on these connections to open the linking page would be totally enough.
Now my noob question: What’s the best way to achieve displaying these “incoming” connections?
Using a pages select field with the “disabled” option and a proper “query” property?
Or writing a little panel plugin that displays all pages with their panel links, based on a proper query?
Or is there some solution out there already wich I missed?
Gotta ask again, since I’m just trying to implement this using the plugin you mentioned.
The plugin works. But I’m not experienced enough with the query language to create a query that delivers the pages I’d like to display.
What I want to achieve sounds rather simple: In the blueprint of pages with the template “topic” I want to display a list of pages …
with the template “talk”
and which have the current topic selected in a pages field called “topics”.
Means: In the panel view of a “topic” page, I would like to display which “talk” pages are related to the current “topic”. While editors can’t change this relationship directly in the “topic” page panel view, they can click on one of the “talk” pages in the pagesdisplay section and change the relationship between the talk and its topics there. Comfortable enough.
The “topics” pages field of a typical “talk” page looks like this in a content file:
So I thought of something like this as a first – not yet dynamic – try in my “topic” blueprint:
sections:
relatedTalks:
type: pagesdisplay
headline:
en: Talks with this topic
de: Vorträge zu diesem Thema
query: site.index.template("talk").filterBy("topics", "*=", "L5A6jcOAzVACFi6r")
But the filterBy part has no effect in my tests.
Of course, the "L5A6jcOAzVACFi6r" string needs to be replaced by a reference to the UUID of the current “topic” page anyway.
I have a similar use case, but simplified (only a global set of “tag” pages, which can be assigned to any other collection on the site - like notes, projects, links…) and therefore linking similar content together (like a note about photography, some photo project and a link to an awesome camera for example).
I hit the same roadblock as you, when trying to get the list of all site’s content, matching the currently active tag page (think browsing “photo” tag-page to get all the related notes, projects, links…).
Is there a way to filterBy by the active page’s UUID?
(I’m a PHP/coding newbie, so any help would be appreciated!)
On Kirby 4 btw (forgot to mention this before).
In my “pag-page” template (or controller):
<!-- get current page's uuid -->
<?php $currentUUID = $page->uuid(); ?>
<!-- get all content (except 1st level pages) -->
<?php $allContent = $pages->children(); ?>
<!-- filter all content based on the current page's uuid (note that the "tag-page" collection is called "Tagy" here -->
<?php $taggedContent = $allContent->filterBy('Tagy', '*=', $currentUUID); ?>
<ul>
<!-- list all matching posts, projects, links.. -->
<?php foreach ($taggedContent as $content): ?>
<li>
<a href="<?= $content->url() ?>">
<?= $content->title(); ?>
</a>
</li>
<?php endforeach ?>
</ul>