1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Yes/No or Checkbox to control access to a menu item

Discussion in 'Community' started by guyfromnola, Oct 11, 2019.

  1. guyfromnola

    guyfromnola New Member

    Level: Community
    Is there a way one might go about creating a yes/no, checkbox, or radio element that would allow for allowing/disallowing access of a user to a particular registered user's menu item?

    I have a dropdown menu that is accessible to registered users upon login. However, I have a need for front-end account administrators to be able to set (via creating or editing a user's profile) whether they are able to access a particular link in that dropdown menu (essentially, conditional based on the setting in the profile). I thought about trying to do this with manipulating groups in the Joomla architecture that way, but front-end account administrators are currently not able to access a user's group setting (public, registered, staff, admin, super admin, etc)...intentionally. Also, because I have several menu items I need to manage in this fashion, groups don't seem the most streamlined way to achieve this.

    Is there a straightforward way to achieve this via Fabrik without involving group settings?

    Thanks!
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    So you are talking about a Fabrik dropdown element, and hiding certain options in that depending on a setting in their profile?

    If so ... I'd make it a join element, rather than a dropdown. Create a Fabrik list with it's own table to contain the options, with an additional field for the access control ...

    id, label, access
    1, Blue, 1
    2, Red, 0
    3, Green, 1
    4, Orange, 0

    Change the dropdown element to a join element, with value 'id' and label 'label', then a WHERE clause like this ...

    Code (Text):

    {thistable}.access = (SELECT access_control_element FROM your_profile_table WHERE user_id = '{$my->id}')
     
    Then if access_control_element is (say) a yesno (values 0 and 1), only the rows with an 'access' that matches that setting will show. You could extend that to multiple values for the access_control_element. And ... if you do eventually move to actual group ACL's, you could change it to be group ID based, by putting the group ID in the 'access' field and changing that query slightly.

    -- hugh
     

Share This Page