Templates for Laravel

Asked

Viewed 901 times

1

I am starting a system that will be the basis of all systems in the company.

The system will develop in Laravael 4 and the interface will be a theme of wrapbootstrap.

What would be the best practices to use my layout as a library/package for my future projects?

  • I recommend using this plugin for managing templates: https://github.com/teepluss/laravel-theme

2 answers

2


I have done what you are doing a few times and in my case I thought better to punch the whole theme, each corresponding piece there is some element of the layout(header, footer, sidebar etc.) this way is better to reuse just using @include(') so most of the time my structure gets like this:

views
--layouts
----master.blade.php(estrutura do html)
----partials
------sidebar.blade.php
------header.blade.php
------footer.blade.php
------styles.blade.php
------scripts.blade.php
------navigation.blade.php
------alerts.blade.php
  • Man, interesting, in case there would be no way to create a librarie or package? Another thing, to make it easier to upgrade to L5 and new layout version? It is better to use Form or plain html code?

  • I was thinking here too, if you could set the layout in the general controller, instead of setting in each view using "use".

0

What I solved:

following Richard’s idea follows my structure:

views
--layouts
----master.blade.php(estrutura do html)
----sections (alteração minha)
------sidebar.blade.php
------header.blade.php
------footer.blade.php
------styles.blade.php
------scripts.blade.php
------navigation.blade.php
------content.blade.php (será usado para carregar a view que a rota definir)
------alerts.blade.php

My final question was whether I could set a template for a controller instead of using USE in each view. Here’s the answer to my question:

http://laravel.com/docs/4.2/templates

class UserController extends BaseController {

/**
 * The layout that should be used for responses.
 */
protected $layout = 'layouts.master';

/**
 * Show the user profile.
 */
public function showProfile()
{
    $this->layout->content = View::make('user.profile');
}

}

Thanks a lot.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.