Does anyone know how my layouts.default
can load multiple views every time they are called. For example I want to call the views of the menus and the menu.blade.php
file has to receive data as well.
Does anyone know how my layouts.default
can load multiple views every time they are called. For example I want to call the views of the menus and the menu.blade.php
file has to receive data as well.
I use the View::share("variável", "valor");
method to share variables between all views ... but I believe there should be better methods ...
ex.:
//No controller public function minhaAction(){ View::share("menu", array(...)); //a variavel $menu estara disponivel em todas as views... return ...; }
Another way would be to create View and move to main as?
menu.blade.php
<h1>{{$model['Titulo']}}</h1>
view.blade.php
<html>
<head>
<title>View Principal</title>
</head>
<body>
{{$model['cabeca']}}
{{$model['menu']}}
{{$model['rodape']}}
</body>
</html>
método de carregamento
$cabeca = View::make("menu")->with('model', array('Titulo' => 'Cabeça do Site'));
$menu = View::make("menu")->with('model', array('Titulo' => 'Menu do Site'));
$rodape = View::make("menu")->with('model', array('Titulo' => 'Rodapé do Site'));
return View::make("view")->with('model', array('cabeca' => $cabeca,
'menu' => $menu,
'rodape' => $rodape));
Result
Hmtl result
<html>
<head>
<title>View Principal</title>
</head>
<body>
<h1>Cabeça do Site</h1>
<h1>Menu do Site</h1>
<h1>Rodapé do Site</h1>
</body>
</html>