Redirecting front-end routes to Dashboard in Bolt CMS

567 Views Asked by At

I'm trying to redirect front end routes to the admin dashboard, as I'm using the Bolt installation as a REST API back end. Here's how I'm routing the content:

contentlink:
  path:               /{contenttypeslug}/{slug}
  defaults:           { _controller: 'Bolt\Controllers\Backend::dashboard' }
  requirements:
    contenttypeslug:  'Bolt\Controllers\Routing::getAnyContentTypeRequirement'

So, all I've done is use the dashboard controller. When I try to visit one of those routes, I get the following whoops error:

Twig_Error_Loader
Template "dashboard/dashboard.twig" is not defined ()

So for some reason it's not looking in the correct place for the template. Is there a way to correct this?

1

There are 1 best solutions below

0
On

This looks like it's to do with the Twig path which is setup differently depending on whether there is a frontend or backend request.

you can always add a path to the Twig environment that Bolt uses with the following call:

$app['twig.loader.filesystem']->prependPath("/path/to/twig");

The path to the backend twig templates may vary but usually this will work.

$path = $app['resources']->getPath('app/view/twig');
$app['twig.loader.filesystem']->prependPath($path);