0

I want to generate about 40 buttons on the same page, every button should be visible to only a certain group of people based on their Drupal roles.

What the best way to do it ? I thought about creating a bloc for every button but to display them with visibility restriction in the Block layout and restrict every bloc by role..but it's not very efficient and the Block layout page will be full of those blocs.

Does anyone have any suggestions ?

Thank you

1 Answer 1

1

you can simply create different class for each type color and based on the role you can add the class to the button.

4
  • 1
    Hi @Gaurav, could you elaborate your answer with some snippets of code to guide OP in the right direction? At least try to provide the different hooks and theme functions. Thanks! Commented Mar 8, 2017 at 12:03
  • @Gaurav Rajdeo, I don't really understand how i can link between the class and the role ? Could you elaborate ? Many thanks
    – usethe23
    Commented Mar 8, 2017 at 12:38
  • I would want to know what is your approach to create your buttons. Are you going to do it with forms? Commented Mar 9, 2017 at 7:21
  • It would be easier I guess with the forms because you can add your html elements such as <div class="button_1"></div> in $form['button_1']['#prefix'] and $form['button_1']['#suffix']. So now according to this class you can write css 'background-color' property for each button. Commented Mar 9, 2017 at 7:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.