I'm displaying a list of Packages and within those Packages are Products. The Packages channel entry has a Playa field populated by Product channel entries. So to display them I have something like this:
{packages} {!-- Playa field --}
{exp:playa:children field="packages_products"} {!-- Playa entries --}
{product 1}
{product 2}
{/exp:playa:children}
{/packages)
I have detailed descriptions for the Products that are hidden until clicked on and they expand, using Bootstrap's Collapse plugin. And the issue I'm running into is that I need each Product to have some sort of unique identifier because each Package can have one or more of the same Products.
So looking at the example below you can see that Product 2 is in both Packages. Using Bootstrap's Collapse if you click on Product 2 in Package 1 the details will expand, BUT clicking on Product 2 in Package 2 only expands Product 2 in Package 1. Essentially I need to add some sort of unique identifier to every Product that's repeated across Packages in order for Collapse to work correctly.
{packages} {!-- Package 1 --}
{exp:playa:children field="packages_products"} {!-- Playa entries for Package 1 --}
{product 1}
{product 2}
{/exp:playa:children}
{/packages)
{packages} {!-- Package 2 --}
{exp:playa:children field="packages_products"} {!-- Playa entries for Package 2 --}
{product 5}
{product 2}
{/exp:playa:children}
{/package)
Theoretically I'd be able to grab the entry_id of the Package channel entry that the Product Playa entry is in, so something like this:
{packages} {!-- Package 1 --}
{exp:playa:children field="packages_products"} {!-- Playa entries for Package 1 --}
{product 1}
{product 2-1}
{/exp:playa:children}
{/packages)
{packages} {!-- Package 2 --}
{exp:playa:children field="packages_products"} {!-- Playa entries for Package 2 --}
{product 5}
{product 2-2}
{/exp:playa:children}
{/package)
But I've tried for the last few hours and haven't figured it out. Any thoughts?
UPDATED More specific code from my template:
{films_packages_products}
{exp:playa:children field="packages_products"}
<h3>{packages_name}</h3>
<ul>
<li>
{products_summary}
{!-- need a unique id for the Collapse js to target next line --}
<a data-toggle="collapse" data-target="#{unique id}_{url_title}">More Info</a>
{!-- need a unique id for the Collapse js to target next line that matches the above --}
<div id="{unique id}_{url_title}" class="collapse">
{products_features}
<li>{feature_bullet}</li>
{/products_features}
</li>
</ul>
{/exp:playa:children}
{/films_packages_products}
html
?