# PagesController "ignores" Pages dir?

**URL:** <https://discourse.cakephp.org/t/pagescontroller-ignores-pages-dir/5087>\
**Category:** Need Help\
**Created:** [October 11, 2018, 9:17am UTC](https://discourse.cakephp.org/t/pagescontroller-ignores-pages-dir/5087 "2018-10-11T09:17:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FinlayDaG33k](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/finlaydag33k/32/1049_2.png) [@FinlayDaG33k](https://discourse.cakephp.org/u/FinlayDaG33k)\
**Post date:** [October 11, 2018, 9:17am UTC](https://discourse.cakephp.org/t/pagescontroller-ignores-pages-dir/5087/1 "2018-10-11T09:17:52Z")

</div>

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:

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

```

and in the navbar, I have the following link:

```auto
<?= $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:

```auto
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:

```auto
<?= $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` ☹  
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:

```auto
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…
