PagesController "ignores" Pages dir?


#1

I am currently trying to port my old, unfinished website to a new CMS we are building at work.
Both run using CakePHP 3.6.
The old site is just directly build into CakePHP itself whereas the new site is a plugin, so please keep that in mind while I’m explaining this.

In my original site I have the following route:

Router::scope('/about', function (RouteBuilder $routes) {
  $routes->connect('/me', ['controller' => 'Pages', 'action' => 'display', 'about/me']);
});

and in the navbar, I have the following link:

<?= $this->Html->link('Me', ['controller' => 'Pages', 'action' => 'display', 'about/me'], ['class' => 'dropdown-item']) ?>

This works like a charm in the old site, however, in the new site, it’s a completely different story.

I have copied the PagesController into the plugin’s Controller directory and added the following route to the plugin:

Router::plugin('Werkwent/Finlaydag33k',['path' => '/about'],function ($routes) {
    $routes->connect('/me', ['controller' => 'Pages', 'action' => 'display', 'about/me']);

    $routes->fallbacks(DashedRoute::class);
});

I then added the link in the navbar like this:

<?= $this->Html->link('Me', ['plugin'=>'Werkwent/Finlaydag33k','controller' => 'Pages', 'action' => 'display', 'about/me'], ['class' => 'dropdown-item']) ?>

Reverse routing works properly, so that is great, but when I click it (and thus go to /about/me), I get a MissingTemplateException :frowning:
In the error, it says It looks for the file at these places:

  • /var/www/src/Template/Plugin/Werkwent/Finlaydag33k//about/me.ctp
  • /var/www/plugins/Werkwent/Finlaydag33k/src/Template//about/me.ctp
  • /var/www/src/Template//about/me.ctp

However, it should be looking in /var/www/plugins/Werkwent/Finlaydag33k/src/Template/Pages/about/me.ctp (which is where the file is).
It literally just strips the Pages out of the location it should look.

A different route that I’ve added looks like this:

Router::plugin('Werkwent/Finlaydag33k',['path' => '/'],function ($routes) {
  $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']);

  $routes->fallbacks(DashedRoute::class);
});

and this one does look in the Pages dir…
What’s going on?

UPDATE: I’ve fiddled around with it the entire day, but the only solution I could find was to change about/me to Pages/about/me
But this shouldn’t have to be done in the first place.
What I wonder is why this bug happens in the first place since it does just truncated the Pages part from the path which shouldn’t happen in the first place…