Jump to content

Recommended Posts

Posted

Hello,

I need some advice on what is the best option to set permissions for Repeater Matrix. I am using a Repeater Matrix with multiple Repeater Matrix types in a template. The main Repeater_matrix_field consists of around 10 items with image, text fields and various layouts. What I am trying to do is to limit permissions and prevent a user role from editing. How can I restrict access to certain Repeater Matrix types so that all fields are locked except 2 Repeater Matrix types? Is that possible? 

Repeater_matrix_field structure:

1. Repeater Matrix item: Full size image field
2. Repeater Matrix Item  Two Column text fields
3. and 4. Repeater Matrix Item. The only field that the user should be allowed to edit
5. Repeater Matrix Item: Text Teaser fields
6. Repeater Matrix Item: Full size image field
7. Repeater Matrix Item: Two Column text fields

 

What is the most elegant way to set the permissions? 

Option A. I have looked into RestrictRepeaterMatrix module. However it still possible to modify and delete existing Repeater Matrix types.

Option B. Usually I would add a separate field with individual permissions, but adding 2 more Repeater Matrix duplicates seems to be overkill. Also both fields are located in the middle of the Repeater Matrix field. The option to change the item order is essential.

I hope this makes sense. I really appreciate any reply. 

Posted

I assume you want those other RM types that should not be editable by the user with the given role still to be shown in admin, but with all their fields being disabled.

The best way to achieve this is via hooks. Look here or search for similar topics for inspiration. Check RestrictRepeaterMatrix's source code for another example.

You need to get the InputfieldRepeaterMatrix field at some point (maybe after the renderReadyHook method), foreach through the blocks and change their fields' output based on your conditions.

Sorry for no ready-to-copy-and-paste code))

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...