Sitelok menu based on groups


(Sean Larkin) #1

I m not sure if this is possible or not but I would like to do the following:

Have groups 1,2,3 and a menu like below

Link 1 (Available to groups 1,2 & 3)
Link 2 (Available to group 1)
Link 3 (Available to groups 1,2 & 3)
Link 4 (Available to groups 2 & 3)
Link 5 (Available to groups 1 & 3)

Or something along these lines. Is this possible?


(Mathew Mitchell) #2

Yes, what you wrote is certainly possible. The key is all links are available to everyone, but some links won’t work if you are not part of the right group (essentially you’ll be told you don’t have access).


(Brandon Scott Corlett) #3

Here is how I coded my foundation menu to only display certain menu items for admins and/or members.

<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='/products'>Products</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/products/admin'>Admin</a></li>
	<li><a href='/admin/products/article'>New Product</a></li>
    </ul>
    <?php } ?>
</li>
<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='/services'>Services</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/services/admin'>Admin</a></li>
	<li><a href='/admin/services/article'>New Service</a></li>
    </ul>
    <?php } ?>
</li>
<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='/blog'>Blog</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/blog/admin'>Admin</a></li>
        <li><a href='/admin/blog/article'>New Post</a></li>
    </ul>
    <?php } ?>
</li>
<li><a href='/forum' target='_blank' >Forum</a></li>
<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='/demo'>Demo</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/demo/admin'>Admin</a></li>
    </ul>
    <?php } ?>
</li>
<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='/contact'>Contact</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/contact/admin'>Admin</a></li>
    </ul>
    <?php } ?>
</li>

<?php if (sl_ismemberof("ADMIN")){ ?>
<li class='has-dropdown'><a href='/documentation/'>Public Documentation</a>
    <ul class='dropdown'>
        <li><a href='/admin/public-documentation/'>Admin</a></li>
	<li><a href='/admin/public-documentation/document'>New Document</a></li>
    </ul>
</li>
 <?php } ?>

<?php if (sl_ismemberof("ADMIN")){ ?>
<li class='has-dropdown'><a href='/private-documentation/'>Private Documentation</a>
    <ul class='dropdown'>
	 <li><a href='/admin/private-documentation/'>Admin</a></li>
        <li><a href='/admin/private-documentation/document'>New Document</a></li>
    </ul>
</li>
 <?php } ?>

<li <?php if (sl_ismemberof("ADMIN")){ ?>class='has-dropdown'<?php } ?>><a href='#' class='glider-toggle' data-glider='donate-glider'>Funding</a>
   <?php if (sl_ismemberof("ADMIN")){ ?>
    <ul class='dropdown'>
        <li><a href='/funding/admin'>Admin</a></li>
    </ul>
    <?php } ?>
</li>

<?php if ($slpublicaccess) { ?>
<li><a href='#' class='glider-toggle' data-glider='login-glider'>Login/Register</a></li>
<?php } // Hide ?>

<?php if (!$slpublicaccess) { ?>
<li class='has-dropdown'><a href='/demo'><?php echo $slname; ?></a>
    <ul class='dropdown'>
       <li><a href="/admin/demo/">Account Settings</a></li>
     <?php if (sl_ismemberof("ADMIN")){ ?>
       <li><a href="/slpw/">Admin Settings</a></li>
     <?php } ?>
       <li><a href="/slpw/sitelokpw.php?sitelokaction=logout">Logout</a></li>
    </ul>
</li>
<?php } ?>

(Sean Larkin) #4

Brandon, thank you. That is exactly what I was looking for.


(Brandon Scott Corlett) #5

You are very welcome. I’m happy I could help.