I am creating an application where there are two user types. This is determined upon user creation. This field is located in Meteor.users.userType: publisher
or it can be userType: reader
.
Apart from both userTypes sharing the same home page (which will also be public), everything else between the 'publisher' and 'reader' will be totally different. E.g template layout, navigation, data passed in.
Should I use spacebars {{#if}} block and only show relevant paths available for the userType as I've done similarly in the signup/login paths in my example below using iron:router? This way, I would be using many if statements to declare templates and functionality depending on userType many times over.
So far, as the userTypes have different user profile data structures, I am simply calling the desired fields that each userType needs to see. On the face of it, this is seems fine as I've created separate templates and paths for both userType. But there must be a better convection that includes declaring the userType when the application starts up.
Eg. Is it possible to determine the userType with iron router as soon as the user logs in? So if userType is 'reader', the code could branch to a particular routing configuration, and if userType is 'publisher', the code could branch to a another routing configuration?
I would like to exhaust a few ideas before committing to the application structure.
<template name="appBody">
<ul class="nav nav-tabs" role="tablist">
<li><a href="{{pathFor 'allPosts'}}">All Posts</a></li> // public home page
<li><a href="{{pathFor 'profilePagePublisher'}}">ProfilePage Publisher</a></li> //for userType: publisher
<li><a href="{{pathFor 'createPost'}}">Create Posts</a></li> //for userType: publisher
<li><a href="{{pathFor 'profilePageReader'}}">ProfilePage Reader</a></li> //for userType: reader
<li><a href="{{pathFor 'readingList'}}">Reading List</a></li> //for userType: reader
{{#if currentUser}}
<li><a class="logout btn-secondary" href="#">Logout</a></li>
{{else}}
<li><a href="{{pathFor 'signin'}}" class="btn-secondary">Sign In</a></li>
<li><a href="{{pathFor 'join'}}" class="btn-secondary">Join</a></li>
{{/if}}
</ul>
{{> yield}}
</template>
Thank you in advance for considering to help.
You can try using dynamic template includes. Create 2 templates called 'publisher' and 'reader' and then in the parent template include them like this: