Am loving Fuel and finding it very easy to use. I've got my MVC all setup and working correctly. For my project, I want to add a single menu item dependant on user roles
eg
User 1 (basic user): Add | Edit
User 2 (super user): Add | Edit | Delete
For best practice, should
a) I swap templates and views from the controller dependant on user roles (seems overkill and duplication of view code for a single additional menu item)
b) add "if statements" to my views dependant on user roles (documentation says views really should have minimal logic code)
c) another approach I'm not familiar with
Method A and B will work but both don't seem to be best practice.
Thanks
Good question.
I always utilize the method "b" that you stated. But sometimes i don't feel that is the best way to do it too.
I would like to know too if besides using a template engine is there anyway to make the code, in this case, better and more organized?
If the complexity can be managed I would go for b as well.
If it gets to complex (like you have for example in a CMS where menu items are completely configurable I would abstract it away in a support class that would have it's own views to generate only the HTML for the menu, and use that output to echo it out in your page template.