Exclude a page from the search in the panel

Hello,
I have identified a problem in the search for the panel.

When I search for a page, no pages are found.
I just figured out why.

I created a virtual page to display the list of members:

website.com/members/
website.com/members/firstname-lastname

When I comment out the model the search works again.

I think the solution would be to exclude this page from the search.
Is it possible to exclude a page from the panel search?

This should help:

Bit weird that search stops working with virtual pages, though. I’d consider this a bug if it can be reproduced. Please provide steps to reproduce this issue.

What Kirby version are you using?

Kirby 3.8.2
PHP 8.0

Thanks, I’ll look at the documentation.

It probably bug because it tries to list users?

I used the following example:

<?php
class MembersPage extends Page
{
  public function children()
  {
    $usersPages = [];
    $users      = kirby()->users();
    foreach ($users as $key => $user) {
      $userPages[] = [
        'slug'     => Str::slug($user->firstname() ." ". substr($user->id(), 0, 3)), // or username if unique
        'num'      => $user->indexOf($users),
        'template' => 'member',
        //'model'    => 'members',
        'member_url'    => $user->firstname() ." ". $user->namefamily(),
        'content'  => [
          'user'    => $user,
          'name'    => $user->name(),
          'title'    => $user->firstname() ." ". $user->namefamily(),
          'firstname'    => $user->firstname(),
          'namefamily'    => $user->namefamily(),
          'member'    => $user->member(),
          'sex'    => $user->sex(),
          'birthday'    => $user->birthday(),
          'street'    => $user->street(),
          'zip'    => $user->zip(),
          'city'    => $user->city(),
          'country'    => $user->country(),
          'phone'    => $user->phone(),
          'phonemobile'    => $user->phonemobile(),
          'licence_date'    => $user->licence_date(),
          'size'    => $user->size(),
          'weight'    => $user->weight(),
          'bio'    => $user->bio(),
          'url_strava'    => $user->url_strava(),
          'photo'    => $user->file(),
          // Options du select
          'options'    => $user->blueprint()->field('sex'),
          // Structure
          'social_events_listing'    => $user->social_events_listing()->toStructure()->toArray(),
           // more fields here
        ]
      ];
    }
    return Pages::factory($userPages, $this);

  }
}

I just tested this:

I comment out these 2 lines and the search works again?!

          // Options du select
          'options'    => $user->blueprint()->field('sex'),
          // Structure
          'social_events_listing'    => $user->social_events_listing()->toStructure()->toArray(),
           // more fields here

EDIT:
If I remove this the search works (but the code of my template will no longer work correctly).

->blueprint()

->toArray()

I’m having this problem as well, I have a website that runs on Kirby 3.9, but a virtual page causes the panel search to collapse.

Is there a way to exclude these pages from the panel search?

Have you set the children property? The code exsmple above is not best practice. Please see virtual content guide.

1 Like