On Posts, Pages, and Custom Post Types, designate available templates with the static getAvailableTemplates
method. Post template values are available in views with the $__template
variable.
class Project extends Post implements CustomPostType
{
public static function getAvailableTemplates() {
return ['one-column', 'two-column'];
}
Easily switch between templates and custom pages below with this in your blade file. Just add blade files named after your available templates in the resources/template
folder. (i.e.: one-column.blade.php
and two-column.blade.php
)
@if (isset($__template))
@include('template.' . $__template)
@else
@yield('content')
@endif