Unintended Redirection to the Template After Creating a Child Page

I don’t know if it’s a bug or intended, but how can I change it:

My use case:
In the panel, I have the option to create subpages for a page, but these should be displayed as sections on the parent page. Therefore, I’ve used the following code as the template for the subpages:

<?php
$pageUrl = $page->parent()->url() . “/#” . $page->slug();
go($pageUrl, 301);
?>

Strangely enough, when I create a subpage, I’m redirected to the parent page (in the frontend) immediately after clicking “Create.” Logically, though, I’d like to stay in the admin panel and edit the newly created page.

Can anyone help?

Thanks a lot!
Matthias

Redirects should be setup as routes in the config file rather than in the templates.

Alternatively it looks like you are trying to create a one page website but using sub pages for content. have a look at this cook book guide for ideas on how to go about this.

But isn’t it strange that, after creating a page, the corresponding template is apparently loaded without me having clicked the open/preview button?

The most common intent when people create a page is also to edit its content. That’s why the default in Kirby is that when you create a page, right after it leads you to the page’s view so you could edit the content right away.

Sometime that is not the desired behavior, as in your case. For that, have a look at the redirect option of Page blueprint | Kirby CMS

The most common intent when people create a page is also to edit its content. That’s why the default in Kirby is that when you create a page, right after it leads you to the page’s view so you could edit the content right away.

of course, I know that, and this is what I want, but it doesn’t work! :frowning:

And what really surprises me:
When I change the page template (as a test, I simply changed the template to

<h1><?= $page->title()->html() ?></h1>

), everything works as expected — I’m redirected to the page’s edit view in the panel.

here is my blueprint of the child-page:

title: Download-Bereich

image:
  back: "rgba(61, 98, 168, 0.1)"
  color: "rgba(61, 98, 168, 1.0)"
  icon: folder
  query: false

status:
  draft:
    label: Entwurf
    text: Der Download-Bereich ist im Entwurfsmodus und kann nicht öffentlich gesehen werden.
  listed:
    label: Öffentlich
    text: Der Download-Bereich ist veröffentlicht und wird auf der Homepage angezeigt.

sections:
  downloads:
    label: Downloads
    type: files
    batch: true

here ist the blueprint of the parent page:

title: Seite Downloads

image:
  back: "rgba(61, 98, 168, 0.1)"
  color: "rgba(61, 98, 168, 1.0)"
  icon: download
  query: false

tabs:
  content:
    label: Seiteninhalt
    icon: document
    columns:
      - width: 2/3
        sections:
          downloads:
            label: Download-Bereiche
            type: pages
            batch: true
            templates:
              - download-bereich
            empty: Keine Download-Bereiche
      - width: 1/3
        fields:
          protection: fields/locked-pages
  header: tabs/page-header
  files: tabs/page-files

here is the template of the child-page:

<?php 
$pageUrl = $page->parent()->url() . "/#" . $page->slug();
go($pageUrl, 301);
?>

I cannot reproduce this with the blueprints and code you shared. Using the same setup (just removed the other referenced tabs from the parent blueprint), I can create a child page in the Panel, it gets created, Panel shows me the child’s Panel page view.

Do you have any plugins installed?

yes I have:

fendinger/consent-gate
grommasdietz/hidden-characters
johannschopplich/locked-pages
medienbaecker/alter
sylvainjule/embed
timnarr/imagex

To find out what is causing the issue on your install, I would start by removing all from the plugin folder, see if the issue persists/now works correctly. And add back one by one to narrow down to which might cause the problem for you.

Thanks!

I did what you suggested, and the “Kirby Consent Gate”-Plugin causes the problem. :frowning: