I am very new to Yii and I’m slowly coming to grips with it.
I have decided to have a go at moving our current sales system over to Yii.
My question is are there any best practices for outputting a series of navigation links/icons based on a users level, determined by a session variable ‘level’?
I was thinking something like:
<div id="mainmenu">
<?PHP
if($_SESSION['type'] == 1){include('admin-nav.php');} // Load type and level specific menu items.
elseif($_SESSION['type'] == 2){include('sales-nav.php');} // Load type and level specific menu items.
else{} // Type not set or recognised, send to log-in screen.
?>
</div><!-- mainmenu -->
yes you can create a widget or you can render a partial alternatively
this how i did it in my recent project
I created many to many relationship between user and roles, user can have many roles then i created a widget i pass in the params the widgets checks for certain role and display the navigation.
there are extensions available for this task as well
In terms of roles I have user ‘levels’ as well as ‘types’, which I think will be fine as far as ‘user roles’ in the database. I just need an efficient way of implementing this to control the navigation and access to certain functions throughout the system.