Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: setting the layout on object level #41

Closed
happyDemon opened this issue Oct 21, 2014 · 1 comment
Closed

Question: setting the layout on object level #41

happyDemon opened this issue Oct 21, 2014 · 1 comment

Comments

@happyDemon
Copy link

Hey there, I've just started using Plates and find it to be an awesome project.

However I was wondering about something, namelyI find it to be a slight hassle having to define the parent layout in every template file, manually.

Wouldn't it be easier to also have the ability to define a master layout on object level, making it easier to change it if needed and not having to hard-code it in every template file.

I want to stress I'm new to plates, so if there's any functionality like this is already in place would you mind pointing me in the right direction?

Thanks ^^

@reinink
Copy link
Contributor

reinink commented Oct 22, 2014

Hey @happyDemon, thanks for stopping by. I'm happy to help answer your question.

Currently this is not possible with Plates. The biggest reason being that you don't want all your templates to implement the master layout. Plates encourages breaking templates into smaller, reusable pieces that together "build up" your pages. Many of these smaller templates don't implement the master layout. Consider things like sidebars, reusable blocks of content, emails, etc.

Generally defining a layout for each page works out well anyway, since you'll often want to pass data it, such as a page title:

<?php $this->layout('template', ['title' => 'User Profile']) ?>

Further, since Plates abstracts the filesystem away from the templates, you really shouldn't have to change the layout very often, if ever. For example, almost all my projects reference the layout at partials/template.

Hope that makes sense!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants