To make the modal popups in your Webflow CMS collection only open individually instead of all at once, you will need to add some custom code and apply a unique identifier to each modal.
Here's a step-by-step guide:
1. Add a unique identifier field to your CMS collection: In your Webflow CMS collection, create a new field (e.g., "Modal Identifier") to assign a unique identifier to each CMS item that will trigger the modal.
2. Insert the modal element into your CMS collection template: Drag and drop the modal element into your CMS collection template where you want it to appear. Make sure it's positioned correctly and styled as desired.
3. Add interactions to the modal trigger button: Select the trigger button for your modal and go to the Interactions panel. Create a new interaction that triggers on a click event.
4. Configure the interaction: In the interaction settings, add two actions. First, set the modal element to display (e.g., "Show Modal"). Second, add the following custom code to set a unique identifier for the modal:
```javascript
var currentItem = $(this).closest('.w-dyn-item');
var modalIdentifier = currentItem.attr('data-item-identifier');
$('.modal').attr('data-modal-identifier', modalIdentifier);
```
This code uses jQuery to find the closest CMS item and retrieve its unique identifier value. It then assigns this value as a data attribute to the modal element.
5. Apply the interaction: Apply the interaction to the trigger button and set it to affect the modal element you added in step 2.
6. Modify the modal settings: With the modal element selected, go to its settings panel. Add a custom attribute to the modal element with the name "data-modal-identifier" and leave the value empty. This attribute will be dynamically populated with the unique identifier for each modal when triggered.
7. Conditional visibility on the modal: Now you need to conditionally display the modal based on its unique identifier. Select the modal element and set its visibility to hidden by default.
8. Add custom code to show the matching modal: Add the following custom code to the page:
```javascript
$('.modal-trigger-button').click(function(e) {
e.preventDefault();
var modalIdentifier = $(this).closest('.modal').attr('data-modal-identifier');
$('[data-modal-identifier="'+modalIdentifier+'"]').show();
});
```
This code listens for a click on any modal trigger button and retrieves its corresponding unique identifier. It then shows the modal that matches the identifier.
9. Save and test: Save your changes, publish your site, and test the modal behavior on your collection items. Each item should now open its respective modal individually.
Remember to replace `.modal` with the actual class name of your modal element, and `.modal-trigger-button` with the class name of your modal trigger button.
By following these steps, you can ensure that only the respective modal associated with each CMS item will open when its trigger button is clicked.