General question on the logic of a kirby website

Hello, hope you are all well.
I like Kirby more and more, but I am stuck on a question of logic on how to organize the logic of a website. Imagine I have a site for an art gallery, I have a serie of exhibitions with dates and different artists taking place at the events. And I also want to have a section on the site with the biography of the artists.
What is the logical way to add a link in the exhibition to the artist’s bio and in the artist’s page links to the exposition he took part in? In the panel, for me, it would be more convenient to have a section with the exhibitions and a section for the artists.
I’m missing this logic, and don’t know yet where to look (I’m still not a programmer at all), I would benfit greatly of this function…
Thank you in advance for your help

Yes, it makes sense to have one parent for exhibitions and one parent for artists.

If you assign an artist to an exhibition ( via a pages field that queries the artists), there is no need to also do it the other way round. Because to get all exhibitions and artist took place in, you can simply filter all exhibitions by this artist.

Once again, thank you for your answer. Can you point me on the subject in the getkirby website, because when you say “pages field” it’s still fuzzy in my comprehension. Thanks

1 Like

Thank you, it was there all along and now I see it more clearly how to work with the logic.

Hi there,

We like to use a tags field that is populated with the artists page children via a query (see query section on the previous link)

We do this for several reasons:

  1. Artists are added by simply writing their names, and so they are shown as a simple list of names.
  2. As you start writing the name of an artist, the tags field already suggests the name to you, and you can choose it.
  3. If a show has artists that are not part of the gallery, these can also be added to the tags field by simply writing their names.

This is how it looks:

And this is how it is coded in the blueprint:

		fields:
			artists: 
				label: Participating Artists 
				type: tags 
				options: query
				query: site.find('artists').children
				required: true

Artists that have their own page are stored as page IDs, example: /artists/this-artist
Artists that do NOT have their own page (not from the gallery) are store as simple text, example: Artist Name

In the templates, we then differentiate between artists that have their own page, and those who don’t, with a logic which is similar to this:

<?php $artists = $page->artists()->split(); /* Get artists from tag field as comma separated list */?>
<?php foreach ($artists as $artist): /* For each artist */?>
	<?php if (page($artist)): /* If there is a page with that id */ ?>
		<?= page($artist)->title()->html() ?> belongs to the gallery.
	<?php else: ?>
		<?= $artist ?> does not belong to the gallery.
	<?php endif ?>
<?php endforeach ?>

This is an example output:

We differentiate between those artists who belong to the gallery and those who don’t, because in the former we usually want to, for example, add a link to their names that leads to their pages.

Et voilà!

Good luck

Also, another trick.

On each artist page on the panel, we use a custom section called “pagesdisplay” in order to (only) show all the exhibitions that the artist has participated in, as a list.

This is the blueprint:

		exhibitions:
			headline: Gallery Exhibitions
			type: pagesdisplay
			query: site.find('exhibitions').children.filterBy( 'artists', page.title, ',')
			info: "{{page.artists}} | {{ page.openingdate.toDate('M jS') }} - {{ page.closingdate.toDate('M jS, Y') }}  "

It looks like this:

And clicking on one of these exhibitions takes you to the exhibition panel page. Very convenient.

:slight_smile:

i like that website :wink:

1 Like

Thank you so very much, I will work from there

1 Like