Actually, I am not able to show the Experience Fragment through HTL from the Node Properties. When I include the below HTL in the HTML file, I am getting this error "org.apache.sling.api.request.RecursionTooDeepException:"
<div data-sly-test="${item.innerBannerType == 'with-badges'}" class="badge-wrapper position-relative">
<sly data-sly-resource="${item.fragmentPath}"></sly>
</div>
But when I hard code the path like below, it's working
<sly data-sly-resource="${@path='/content/experience-fragments/we-retail/equipment/master', selectors='content', wcmmode='disabled'}"></sly>
Looking for a solution. Please help!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Ameen_Dev ,
Use this line of code :
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
In place of below line of code in your sightly:
<sly data-sly-resource="${item.fragmentPath}"></sly>
Final sightly code should be like :
<div data-sly-test ="${item.innerBannerType == 'with-badges'}" class ="badge-wrapper position-relative">
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
</div>
Please remove below line of code :
<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
I think you have used the above section as well but MyCustomComponent Model class is not available in your codebase.
Instead of MyCustomComponent, you are using a different model class to get path that are stored in item and you are fetching as ${item.fragmentPath}.
Hi @Ameen_Dev ,
Can you try as below :
<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
<sly data-sly-resource="${@path=cmp.exPath, selectors='content', wcmmode='disabled'}"></sly>
https://sourcedcode.com/blog/aem/dynamically-include-an-experience-fragment-in-sightly
Hope this could help you.
Regards !
Views
Replies
Total Likes
Where would I give this node property -> ${item.fragmentPath} in the above code?
Views
Replies
Total Likes
In place of cmp.exPath :
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
Views
Replies
Total Likes
It's not working. getting a different error.
"com.mysite.models.component.MyCustomComponent cannot be correctly instantiated by the Use API"
Any other way to solve this issue?
Views
Replies
Total Likes
Hi @Ameen_Dev ,
Use this line of code :
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
In place of below line of code in your sightly:
<sly data-sly-resource="${item.fragmentPath}"></sly>
Final sightly code should be like :
<div data-sly-test ="${item.innerBannerType == 'with-badges'}" class ="badge-wrapper position-relative">
<sly data-sly-resource="${@path=item.fragmentPath, selectors='content', wcmmode='disabled'}"></sly>
</div>
Please remove below line of code :
<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
I think you have used the above section as well but MyCustomComponent Model class is not available in your codebase.
Instead of MyCustomComponent, you are using a different model class to get path that are stored in item and you are fetching as ${item.fragmentPath}.
Yeah, you're right. I was using the entire code. By the way, MyCustomComponent doesn't exist that's the reason I was getting that error.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies