Search code examples
meteoriron-router

Using a second master layout


I have one master layout that i have been using for my app.I have a generated my app using iron-cli package and my master layout is called master_layout.html

t i now have a problem. All my app menus are all in he master layout and i need to create a login page that will not require the menus. This can be solved,if i had a second master layout whereby i can strip the menus off my original master layout and use the layout for my login page.

My route looks like this

Router.route('/Limit/ay', {
  name: 'ay',
  controller: 'LimitController',
  action: 'ay',
  where: 'client'
});

and my controller code looks like this

 ay: function() {
      this.render('Ay');
    //this.render('Added', {});
  }

Is there a way i can register a second master layout and use it for my login page?.

If i register another layout

Router.configure({
  layoutTemplate: 'MasterLayout',
  loadingTemplate: 'Loading',
  notFoundTemplate: 'NotFound'
});

Router.configure({
  layoutTemplate: 'GoodLayout'
})

One layout is being used and the other is ignored,so i can only use one main layout at a time.

How can i solve this?.


Solution

  • Just override the layout in your new route:

    Router.route('/Limit/ay', {
      name: 'ay',
      layoutTemplate: 'GoodLayout',
      controller: 'LimitController',
      action: 'ay',
      where: 'client'
    });
    

    The route's version will take precedence over the global layout setting.