Redirect to new page in panel

Hi,

I’m building an event directory, and in order to improve the performance, I’m nesting the events in folders by year and date (with the current 3300+ events listed under one single page the perfomance is not that good).

I want the editors to be able to create their events on the “events” page via the panel, and then move the event programmatically to the correct folder based on the year and month of the event. I’m using hooks to do this, and so far it’s working well, I only have one problem and I’m stuck:

After moving the event to the correct directory, the panel tries to open the page with the “old” url for the page, and of course it can’t find the page. Is there a way to redirect to the new URL manually on the panel after saving the page? I tried using go() but that doesn’t work.

Thanks!

I, too have struggled with a very similar use case in the past.

This is not currently possible, as there is no “backchannel” from the backend hooks to the Panel frontend. There is no way the Panel can be notified of the changed page location.

There are some changes planned in the Kirby core that may enable this in the future; we had a brief conversation on Discord the other day. I just created a ticket on the feedback platform – please upvote and/or add any additional wishes or ideas you have:

Thanks, @sebastiangreger!
Time to look into other solutions then :smiley:

In the meantime, you have my upvote :slight_smile:

If you need a hacky workaround it might be possible to add a redirect in a custom field.
I did something similar for the Modules plugin by redirecting to the parent page via window.location.href: GitHub - medienbaecker/kirby-redirect

Not sure how (or if at all) it’s possible to add this redirect at the right moment though.

Upvoting the feature request is probably the best idea right now.

1 Like

Thanks, @thguenther! I will give this a try sooon, I’m still a bit stuck trying to figure out how to organize the events page.

Also thanks for your work, I use some of your plugins daily! :slight_smile:

Is there any update on this? I’m looking at creating a blog plugin with pages published into a year subfolder but with drafts managed on the main blog page.

Hello everyone,

I was having the same dilema. I found out the following works

Panel::go($somepage->panel()->path());

$page->panel()->path() seemds to deliver the panel URL of the page. in my case after some changes i want to redirect to the parent page, so i am doing this.

'page.update:after' => function (Kirby\Cms\Page $newPage, Kirby\Cms\Page $oldPage) {
    // do something here blablabla
    // ...

    Panel::go($newPage->parent()->panel()->path());
}

so if you can somehow get hold of the new page, you can just call the function to get the panel URL

@squareclouds cannot make this work, I still get this:

image

although the page http://127.0.0.1:8003/admin/pages/events exists and is accessible with this url

hmmmmmmmm. can you please post your code? where are you calling this?