Skip to content

Instantly share code, notes, and snippets.

@rossriley
Created June 18, 2015 19:23
Show Gist options
  • Save rossriley/695b62ade55e6ac88f40 to your computer and use it in GitHub Desktop.
Save rossriley/695b62ade55e6ac88f40 to your computer and use it in GitHub Desktop.
Custom Controller to switch templates
<?php
namespace My\Custom\Controller;
use Bolt\Controllers\Frontend as BoltFrontend;
class Frontend extends BoltFrontend {
public function record(Request $request, $contenttypeslug, $slug = '')
{
parent::record($request, $contenttypeslug, $slug);
if (condition) {
$template = 'xxxxxx';
} else {
$template = 'xxxxxx';
}
$globals = [
'record' => $content,
$contenttype['singular_slug'] => $content
];
return $this->render($template, [], $globals);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment