Created
June 18, 2015 19:23
-
-
Save rossriley/695b62ade55e6ac88f40 to your computer and use it in GitHub Desktop.
Custom Controller to switch templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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