Navigation visible only to Admin
Permalink 1 user found helpful
Hello. I'm not very familiar with PHP and wish to limit the visibility of the nav to Admin only. I read some and tried this, but don't know if it works or how to see or set the permissions.
<?php
$a = new Area('Header Nav');
$p = new Permissions($a);
$p->display($c);
?>
Advice is welcomed.
<?php
$a = new Area('Header Nav');
$p = new Permissions($a);
$p->display($c);
?>
Advice is welcomed.
You can also try:
Note: This would only allow the main admin (not anyone in the 'Administrators' default group) to see this. If you wanted to allow both the super user AND anyone in said group:
If you already are using the advanced permissions model you can control who can see/edit the area as well. I wouldn't turn on advanced permissions if you are only going to use it on this one area. Doing it programatically with either examples shown here would be the best bet.
$u = new User(); if($u->isSuperUser()){ $area = new Area('Header Nav'); $area->display($c); }
Note: This would only allow the main admin (not anyone in the 'Administrators' default group) to see this. If you wanted to allow both the super user AND anyone in said group:
$u = new User(); if($u->isSuperUser() || $u->inGroup(Group::getByName('Administrators'))){ $area = new Area('Header Nav'); $area->display($c); }
If you already are using the advanced permissions model you can control who can see/edit the area as well. I wouldn't turn on advanced permissions if you are only going to use it on this one area. Doing it programatically with either examples shown here would be the best bet.
Beebs93, thanks for that last one. I didn't know you could check for a group. This opens some interesting possibilities. :-)
Hope it helps! :-)