Reputation: 22810
adminController.php
<?php
class AdminController extends BaseController {
protected $layout = 'layouts.admin';
/**
* Show the profile for the given user.
*/
public function register()
{
$this->layout->title = 'admin title';
$this->layout->menu_active = 'register';
$this->layout->content = View::make('pages.admin.register');
}
}
layout/admin.blade.php
<!doctype html>
<html>
<head>
@include('includes.head')
</head>
<body>
<div class="container">
<header class="row">
@include('includes.header')
</header>
<div id="main" class="row">
@yield('content')
</div>
<footer class="row">
@include('includes.footer')
</footer>
</div>
</body>
</html>
includes/head.blade.php
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="Scotch">
<title>@yield('title', 'default title')</title>
<!-- load bootstrap from a cdn -->
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/twitter-bootstrap/3.0.3/css/bootstrap-combined.min.css">
question is
how do i get admin title
on @yield rather then default title
that i set on the controller?
how can i use the $this->layout->variable to pass variables in templates?
Upvotes: 2
Views: 1829
Reputation: 146191
How do I get default title on @yield rather then admin title that i set on the controller?
In your register
method you are setting the title
using following line
$this->layout->title = 'admin title';
You should use {{ $title or 'Default Title' }}
in your view
. Here, or
used to print the default value when the given variable is undefined.
How can I use the $this->layout->variable to pass variables in templates?
The way you are setting the variables right now, for example:
$this->layout->variable = 'value';
Upvotes: 1