Skip to main content
Level 2
7月 22, 2022 12:24 午前 UTC

How to add an Experience Fragment to existing 150 pages without authoring/editing page and roll out pages ?

I have the situation where want to add an Experience Fragment (having button component) to under image component without authoring/editing and roll out all pages. These pages following same template.

このトピックへの返信は締め切られました。

4 の返信

SantoshSai
Community Advisor
Community Advisor
7月 22, 2022 1:13 午前 UTC

Hi @csaini ,

The best plausible approach would be to add through HTL, if it works.

Hard Coded Example
The first example uses sightly to reference an experience fragment, /content/experience-fragments/we-retail/equipment, and the required variation, master. This will only work when the path includes the experience fragment variation path. The value here is hard coded.

<sly data-sly-resource="${@path='/content/experience-fragments/we-retail/equipment/master',
   selectors='content', wcmmode='disabled'}"></sly>


Dynamic Example

In the second example, we can see that our component adapts to the com.mysite.models.component.MyCustomComponent, Sling Model backend, and then it exposes the experience fragment in the exPath property. The value returned from the exPath is ‘/content/experience-fragments/we-retail/equipment/master’.

<sly data-sly-use.cmp="com.mysite.models.component.MyCustomComponent"></sly>
<sly data-sly-resource="${@path=cmp.exPath,
   selectors='content', wcmmode='disabled'}"></sly>
Reference: https://sourcedcode.com/blog/aem/dynamically-include-an-experience-fragment-in-sightly
Hope that helps!
Regards,
Santosh
翻訳
Santosh Sai
csaini作成者
Level 2
7月 22, 2022 2:03 午前 UTC

Firstly, thank you for the quick response.

 

I have a follow up question - my Experience Fragment is based on language copy such as "en-US", "ja-JP", "de-DE" etc.

content/experience-fragments/mysite/en_us/equipment/master

content/experience-fragments/mysite/ja_JP/equipment/master

content/experience-fragments/mysite/de_DE/equipment/master

How to deal exPath in this situation dynamically when page render as JP domain or other domain.
Thanks for the help in advance!

 

翻訳
Level 3
7月 22, 2022 2:18 午後 UTC

If you are working on an Editable template then you can edit it and place new content in structure or initial content section.

翻訳
csaini作成者
Level 2
7月 22, 2022 2:32 午後 UTC

In my case, each page have around 10 components ( banner, text, image, accordion etc) already on the page those are rendering as normal component not as structure or initial. I want to add Experience Fragment below the image component without authoring or roll out page. 

翻訳