Smarty help - show menu items if particular logins

Started by BRJP, February 18, 2015, 02:45:21 PM

BRJP

Dear All,

We are trying to make only certain menu items appear to certain login names within the Control Panel.

We know where the menu pages are but don't know how to program the smarty IF statement to only show the menu item if logon equals a specific set of usernames.

Any ideas ?

Brad
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

BRJP

Anyone have any ideas on how to achieve this? 

In essence, we want to only show certain menu items for a particular user/login.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

Fusionhost

Unfortunately not, although I'd love to know as well
fusionhost - www.fusionhost.co.uk
Leading British Cloud Web Hosting Provider

BRJP

So do I!  This seems to be alluding everyone!
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

hbillclient

#4
Hi,

You could use one of the following variables in smarty to do what you want:

{$login.id}
{$clientdata.email}
{$clientdata.group_id}

These variables contain the client id, email & group id of the currently logged in user.

I did test using the code inside header.tpl of the modernpanel template but, you can just as well try adding the code below to any of hostbill's respective smarty templates, which you need to customise for your clients.

Eg:1
To display a menu only if the login id is 10:

{if $login.id == 10}
{include file="menu.tpl"}
{/if}

Eg:2
Don't show the menu for the client with the email(denied@example.com) and display for others:

{if !$clientdata.email == 'denied@example.com'}
{include file="menu.tpl"}
{/if}

You could probably define an array and check for those ids/emails to define what options would be available for them.

Another thing you could do is create a group in hostbill and add clients to that group, create a customised menu and then use the following in your template:

{if $clientdata.group_id == 1} (Clients having groupid as 1 would have a customised menu)
{include file="custommenu.tpl"}
{else}
{include file="menu.tpl"}
{/if}


Hope this helps. Good luck.

Thanks.

BRJP

Let me play around with this and come back.

Thank you very much for taking the tine to test and write a very clear post.  It is very much appreciated.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/

hbillclient

Hi Bradley,

Did you get the issue resolved and did the code work for you? Would like to hear your thoughts.

Thanks.

BRJP

Quote from: hbillclient on June 02, 2015, 09:54:39 PM
Did you get the issue resolved and did the code work for you? Would like to hear your thoughts.

I am really sorry - I have been so busy that I still haven't got the team to try!  Thats also the reason I have been missing from the forums as well.

I will defy try and report back later next week.
Kind regards,
Bradley Porter
--------------------
Find out more about SaneChoice Services at: https://www.sanechoice.cloud/