Welcome to the THELIA support and discusssion forum


Rejoignez la communauté sur le Discord Thelia :


When I navigate to /cart on my Thelia site, it renders the custom 404 view in templates/frontOffice/myproject/404.html. I suspect this has something to do with my page-based routing scheme, which is supposed to route arbitrary top-level URLs like /some-page to PageController, part of MyProject module, which finds a matching Content record and displays it.

The routing.xml config is supposed make exceptions for special Thelia routes and default to the core's behavior. It seems to be picking up the 404.html view but not via PageController, because any edits to the controller code do not seem to affect what's rendered, even having cleared the cache and viewed the page in dev mode.

What's going on?

Here's my custom module's routing.xml:

<?xml version="1.0" encoding="UTF-8"?>
<routes xmlns=""

    <route id="myproject.home" path="/" methods="get">
        <default key="_controller">MyProject\Controller\PageController::homeAction</default>
    <route id="" path="/rentals" methods="get">
        <default key="_controller">MyProject\Controller\RentalController::indexAction</default>
    <route id="" path="/rentals/{slug}" methods="get">
        <default key="_controller">MyProject\Controller\RentalController::showAction</default>
    <route id="" path="/{slug}" methods="get">
        <default key="_controller">MyProject\Controller\PageController::showAction</default>
        <!-- treat arbitrary top-level routes as pages, except a few special cases that should honor Thelia defaults -->
        <requirement key="slug">^(?!admin|cart|register|login|password|password-sent|logout|account|sitemap|empty)[^/]+</requirement>


Here's my controller code:


namespace MyProject\Controller;

use Thelia\Controller\Front\BaseFrontController;
use MyProject\Model\ContentQuery;
use MyProject\ServicesTrait;

 * Controller for displaying arbitrary pages
class PageController extends BaseFrontController
  use ServicesTrait;

  public function homeAction() {
    $query = $this->getQueryFactory()->createContentQuery();
    return $this->render('index', ['page' => $query->findHomePage()]);

  public function showAction($slug) {
    $query = $this->getQueryFactory()->createContentQuery();
    if ($page = $query->findOneBySlug($slug)) {
      $rendered = $this->render('interior', ['page' => $page]);
    } else {
      die('reached 404 code'); // this doesn't seem to run???
      $rendered = $this->render('404', []);

    return $rendered;

Last edited by ctamayo (13-09-2017 00:40:06)


Um well dur. There's simply no cart.html in our custom module. Turns out in order for the front end to work, you have to implement a front end first. Who knew!


Each module has its own router, and when Thelia resolve a route, the routers are checked one after the other, in the same order as the modules order in the back-office.

So if you want to override standard routes, you have to position your module before the Front module.

OpenStudio Toulouse