Add section about using Page templates #12

Open
jedrzejchalubek opened this Issue Jan 3, 2017 · 0 comments

Projects

None yet

1 participant

@jedrzejchalubek
Member
jedrzejchalubek commented Jan 3, 2017 edited
  • How to register page templates.
  • How to get page template name.
  • How to render different views based on template name.

Should includes snippets like:

  1. Registering templates in Page class.
public function templates()
{
    return [
        'template' => 'Template title'
    ];
}
  1. Access and render views based on template name.
public function show($name)
{
    $page = Post::type('page')->find($name);

    if (! empty($page->template)) {
        return View::make("templates.{$page->template}");
    }

    return View::make('templates.default');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment