This is a kind of weird edge case that relies on a somewhat unique combination of modules, but I'm wondering if anyone else has run into this.

I'm using Entity Embed to embed a custom entity type that uses Owl Carousel inside the WYSIWYG area of another page, using Formatter Field and Formatter Field Preset to select the preset to be used. When doing this, the instance ID that is generated in owlcarousel_fields_field_formatter_view is identical for all instances, meaning that when the carousels are rendered, the same presets are used for all carousels on the page, and they look the same even when they shouldn't.

I don't think that setting the carousel instance ID to owlcarousel-fields-($instance['id']) generates a unique enough ID for this particular case. I'm not sure if using this particular syntax has any special meaning to the devs, but I have found that something like owlcarousel-instance-($entity_type)-($entity_id)-fields-($instance['id']) allows us to get the entity ID of the embedded object into the carousel settings as well, thereby ensuring further uniqueness. In most cases, it shouldn't add too much length to the instance ID.

I've created a patch to demonstrate what I mean. Probably not the highest priority, but if someone could take a quick look at it and let me know if I'm barking up the wrong tree or not, that would be great.

CommentFileSizeAuthor
owlcarousel-instanceid-uniqueness.patch890 bytesgeoffreyr
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geoffreyr created an issue. See original summary.

mariusm’s picture

Thanks,

It's work.

geoffreyr’s picture

Status: Active » Needs review

  • swim committed d115ee2 on 7.x-1.x authored by geoffreyr
    Issue #2594341 by geoffreyr: Instance ID generation means multiple...
swim’s picture

Status: Needs review » Fixed

Interesting case xD; I normally only use context and page manager for element (block) placement. Never embedded Owl inside the WYSIWYG, I can see this is useful for splitting paragraphs up. Seems like others experience this issue as well. Thanks for taking the time to explain the problem, and for providing a patch.

FYI - I'll try and make some time next month to test your accessibility patches.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

ABaier’s picture

Thank you so much! That was exactly what I was looking for.

Solved the following problem for me:
· a view listing nodes by taxonomy term
· view displayed inside page manager/panels
· every node (multiple on page) could have a multi-valued image field
· this image field has the owl carousel field formatter assigned in views

Before I had trouble initiating multiple carousels on one page. Thought this was happening because of the functionality that disables the slider if it has only one slide.

Without the patch every carousel had this class: .owlcarousel-fields-6
Now, the node-id in the class fixes the problems: .owlcarousel-instance-node-3-fields-6