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

Hide list plugin button based on logged in user

Discussion in 'Community' started by jo-ka, May 10, 2021.

  1. jo-ka

    jo-ka Member

    Level: Community
    Hello.
    I have this list, where with the caneditrow plugin, I was able to limit the logged in user to edit his own records (dollar bill icon is the edit button).

    Now, I've created a list plugin, which will take an action on the list rows, but I also need to display only the new plugin button, to the same user, this is, the envelope icon must be displayed only to the user on the row.

    How can I achieve this?

    Thanks in advance.

    upload_2021-5-10_10-17-17.png
     
  2. troester

    troester Well-Known Member Staff Member

    Level: Community
    The php list plugin doesn't have a condition.
    So you must skip your action in the code (anyway, for security reasons).
    If you don't want to show the checkbox you can hide it with custom css.
    To hide/remove the button on certain rows I think you'll need list JS.
    Or do it with a custom template.

    Edit: or with custom CSS addressing the position of your button (hide if 1st child)
     
    Last edited: May 10, 2021
    juuser likes this.
  3. juuser

    juuser Well-Known Member

    Level: Community
    For hiding the button where there's no edit access, something like this should do:

    a.php-1 ~ :not(a.fabrik_edit) {
    display:none;
    }

    where php-1 is your php button "a" element class and .fabrik_edit your edit button "a" element class
     
  4. jo-ka

    jo-ka Member

    Level: Community
    Thanks @troester .
    What if I use update_col plugin instead of a PHP plugin?
     
  5. jo-ka

    jo-ka Member

    Level: Community
    OK, let me check If I can use this suggestion...
     
  6. jo-ka

    jo-ka Member

    Level: Community
    Using update_col, how to use this Check Can Edit option? Is this a way to achieve what I'm looking for?

    upload_2021-5-10_12-34-35.png
     
  7. jo-ka

    jo-ka Member

    Level: Community
    Can't get this working.
    Can I ask you please to post a real example, so I can try with my details? I'm very weak on CSS...
     
  8. juuser

    juuser Well-Known Member

    Level: Community
    Ok, made a quick test and ":not" doesn't seem to work with siblings. But this works (for me):

    .php-1 {
    display:none;
    }
    .fabrik_edit ~ .php-1 {
    display:inline-block;
    }

    P.S. ".fabrik-edit" has to be before ".php-1". And make sure the class is php-1, not php-2 etc.
     
    jo-ka likes this.
  9. jo-ka

    jo-ka Member

    Level: Community
    Yes, perfect, this seems to work. Thanks @juuser.
    upload_2021-5-10_14-51-46.png
     

Share This Page