vlucas / bulletphp

A resource-oriented micro PHP framework
http://bulletphp.com
BSD 3-Clause "New" or "Revised" License
418 stars 50 forks source link

how use different layout under a same route namespace #77

Closed tablecell closed 7 years ago

tablecell commented 7 years ago

for example /admin/login use a plain page without layout /admin/home use admin layout with topbar and sidebar `

$app->path('/admin/', function($request) use($app,$spot) {

$app->path('/login',function($request) use($app){
    $app->config('template.auto_layout','plain');  // use pain layout otherwise use admin layout
  $this->format('html', function()   {
            return $this->template('/admin/login', compact('posts', 'page'));
        });

});

$app->path('/home',function($request) use($app){

  $this->format('html', function()   {
            return $this->template('/admin/home', compact('posts', 'page'));
        });

});
netom commented 7 years ago

The layout can easily be set per response. See docs: http://bulletphp.com/docs/templates/.