Differentiate a post on section's Pages


On one Pages, i create multiple page/post and i wanted to show (on my panel) in different block depending on a specific field. How i can have ?

Hm, in a standard pages section, you cannot filter pages by anything other than template, status or parent. You would need a custom section likes the Pagesdisplay section plugin. The downside of using this plugin as is is that it does not support creating new pages. You would have to extend it to allow that (or add a standard pages section for new pages).


In panel, if i have one page “Fimography” with subpages (“Movies”, “Clips”), i can make a “section” with template filter fort show posts of subpages ?

And other question, in template page, can you filter with a field filter as a select type field ?

Yes, you can filter by the subpages by template in a pages section.

I don’t quite understand what you mean?

Sorry, i’m a french speaking. I try again :slight_smile:

In my template file “Filmography”, how should I filter each section (“Movies”, “Clips”) or a specific field?

Don’t worry. We will get there.

You can filter by a field if you want to have different sections, e.g.

$page->children()->listed()->filterBy('category', 'movies');

If you want to render all children and let the user filter the films by category, you have different options, from a standard select input to purely CSS or JS solutions.

You might want to check out our filtering recipe: https://getkirby.com/docs/cookbook/content/filtering

I’m sorry, i try without success (and read the link in your post).

I have a parent page ‘Discography’ with the child ‘discography-solo’, ‘discography-fgj’, ‘discography-misc’.

In my panel page, i have create three sections. It’s OK :slight_smile:

In parent page, i want to create one block by child/sections. What’s correct formula for filter with ‘field’ or a ‘blueprint’?

I do not know. Is it due to the fact that my file names have a hyphen?

Please, help me :’(

Ok, so you have three sections that use different blueprints. You can now filter them by their intendedTemplate.

Section 1: Discography solo

$soloChildren = $page->children()->filterBy('intendedTemplate', 'discography-solo');

Section 2: Discography fgj

$fgjChildren = $page->children()->filterBy('intendedTemplate', 'discography-fgj');

Section 3: Discography misc

$miscChildren = $page->children()->filterBy('intendedTemplate', 'discography-misc');

The intendedTemplate() is the would-be template defined by the content file name (which depends on the blueprint chosen at page creation).

I try

    <?php foreach ($page->children()->filterBy('intendedTemplate', 'discography-solo') as $soloChildren): ?>
<article class="note">
  <header class="note-header">
    <a href="<?= $soloChildren->url() ?>">
      <h2><?= $soloChildren->title() ?></h2>
      <time><?= $soloChildren->date()->toDate('d F Y') ?></time>
<?php endforeach ?>

That’s OK. This is the right way ?

Yes, that’s fine. I’d name $csoloChildren $soloChild() or something singular, because it’s only 1 item, but that’s up to you.

2 posts were split to a new topic: Include post category in URL