Strange subpage behaviour

#5

I actually added that, to avoid loading the legal page object on the legal page itself. Leaving it out before had the same results, I get the 404 Page with the subpage below it:

if( page('legal')->hasListedChildren() ) :
          $items = page('legal')->children()->listed();
        endif;
0 Likes

#6

The 404 error is probably the result of another problem on those legal children pages themselves.

On a side note, please don’t use the code like this:

if( page(‘legal’)->hasListedChildren() ) :
$items = page(‘legal’)->children()->listed();
endif;

but like I posted above.

0 Likes

#7

Yes, I know :wink: I used your code the above is just to lazyness while testing. Any Idea for debugging the 404?

0 Likes

#8

Is debugging on?

What is in the template these children use?

0 Likes

#9

Sure. The Default template.

0 Likes

#10

Could you post the template these pages use?

0 Likes

#11

Super Simple

<?php snippet('header') ?>

      <article class="main__content">
      <header class="article__header">
        <h2><a href="<?php echo $page->url(); ?>"><?php echo $page->title(); ?></a></h2>
        <time datetime="$page->date('c')"><?php echo $page->date('F dS, Y'); ?></time>
      </header>
        <?php echo $page->text()->kirbytext() ?>
      </article>

<?php snippet('footer') ?>
0 Likes

#12

I also disabled my routes and barbar.js (ajax page loader) the behaviour consists. I just tried adding another subpage for another section, looks like I get the same results for all subpages, indipendent from the footer menu. It’s like the $page objetct gets returned twice.

It does not happen for the blog itself, I can open each article (which are at the end subpages) normally.

I have to digg why this is happening and where I hve the issue in my templates.

0 Likes

#13

I also have the issue on the blog now :man_facepalming: Now everything is falling apart :smiley:

0 Likes

#14

Great! That’s what you wanted, isn’t it?:wink:

0 Likes

#15

Okay - its probably the route:

return [
    [
      'pattern' => '(:any)',
      'action'  => function($uid) {
        $page = page($uid);
        if(!$page) $page = page('blog/' . $uid);
        if(!$page) $page = site()->errorPage();
        return site()->visit($page);
      }
    ],
    [
      'pattern' => 'blog/(:any)',
      'action'  => function($uid) {
        go($uid);
      }
    ]
];

As I copied that blindly earlier when there was an issue with the home setting in an early version of Kirby 3 I don’t have a clue what it is actually doing. :smiley: The blog works if it is enabled, but the rest not.

0 Likes

#16

Are those routes in your config or in a separate file? Because somehow there seems to be the route key missing?

0 Likes

#17

Seperate file

0 Likes

#18

Ok, but these routes look ok and should work without throwing errors on other pages. All the route does is make blog children work without the blog path in it.

0 Likes

#19

Hm okay but then all other subpages that are not under blog do throw the error, right?

/blog/article <- works
/article <-works

/about <- works
/about/test <-breaks
/legal <- works
/legal/privacy-policy <-breaks

0 Likes

#20

But these shouldn’t be affected by the route at all because the patterns don’t apply. The current patterns only listen to something like about, legal, blog etc. or blog/something.

Maybe subpages don’t work at all in your installation? Do they work if you remove the routes?

0 Likes

#21

No, they don’t work. That is really strange, any idea where the issue might be?

0 Likes

#22

Hm, if it was a rewriting issue, I would expect only the Startpage to work. But I don’t know what additional stuff you have working in your project, so it’s hard to tell what’s happening here.

0 Likes

#23

Okay, back to the drawing board then. As I ported stuff from an old kirby 2 theme I created I will reset stuff and check where the issue might be. I’ll keep you posted.

0 Likes

#24

(post withdrawn by author, will be automatically deleted in 24 hours unless flagged)

0 Likes