w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Update parent template's dynamic template include from child template

Use a Session variable?

Template.parentTemplate.helpers({
  // assuming two templates...
  whichMenu: function () {
    return Session.get('whichMenu') ? 'menuTemplate1' : 'menuTemplate2'
    // or just Session.get('menuTemplate'), and you store the template name
there
  }
});

Then

<template name="parentTemplate">
  {{> Template.dynamic template=whichMenu}}
</template>

You can get the current "page" with Router.current(), and Session.set('menuTemplate') accordingly.





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.