I have a custom card component that have Image and texts, but I need to implement an feature that allows Author to change image for video using embed component, that's my code below
Solved! Go to Solution.
Views
Replies
Total Likes
@NathanVieira The above code was to give you an idea as to how you need to update your HTL to include embed component with data-sly-test, Of course you may have to tweak this for your component.
Please make sure that path of resource type is of that of the embed component. And if we correctly apply data-sly-test conditions correctly, we will be able to get a structure shown like below.
Now you can click on the embed component to author video and outer container component - Custom card to edit the required text. Apply required styles.
Hope this helps
Using data-sly-test you can render two different <div> tags based on the condition if an image is authored or render an embed component otherwise.
<div class="cmp-quoteGroupCard--mediaArea">
<div data-sly-test="${image.src}">
<!-- Existing image code -->
</div>
<div data-sly-test="${!image.src}">
<div data-sly-resource="${'embed' @ resourceType='core/wcm/components/embed/v1/embed'}"></div>
</div>
</div>
Views
Replies
Total Likes
It doesn't work, that blocks me to edit embed config or even my custom component config. I need to find a way to have embed structure in my HTL code and using dialog configs to access embed to put a video link, then I'll use sly-test to change option to image or video
Views
Replies
Total Likes
@NathanVieira The above code was to give you an idea as to how you need to update your HTL to include embed component with data-sly-test, Of course you may have to tweak this for your component.
Please make sure that path of resource type is of that of the embed component. And if we correctly apply data-sly-test conditions correctly, we will be able to get a structure shown like below.
Now you can click on the embed component to author video and outer container component - Custom card to edit the required text. Apply required styles.
Hope this helps