Use Experience Fragments in AEM Content Components | Community
Skip to main content
Level 2
Jul 10, 2018 7:14 AM UTC

Use Experience Fragments in AEM Content Components

Hello,

We are using AEM 6.3

Problem Statement:

1. I have a content component - "Hero" on an AEM page - home.html

2. Hero component browses Panel component pages - which means, AEM page with Panel Content Component.

home.html (with Hero) -> panel1.html

                                     -> panel2.html

Problem is how to use experience fragments here for #2.

Proposed Solution:

Instead of using individual AEM pages for Panel component.

Use experience fragments instead.

My Attempt:

1. I created one experience fragment with Panel component.

2. Tried to use in home1.html , home2.html

Issue where I got stuck:

1. How do I associate Hero component and the experience Fragment component. These will be added as 2 individual components on home.html?How will Hero component get data from Panel components? There could be multiple other Experience Fragments components. How could I associate one experience fragment component to Hero component?

2. As far as I know, I cannot break inheritance of experience fragments in AEM 6.3.  My problem is if experience fragment -"ex-panel1" is used on home1.html and home2.html. But in home2.html, the image I want to use a different one, rest of data I can re-use as-is.  I will update ex-panel1 in home2.html alone with new image. Is this the recommended approach? I see things are working fine but just wanted to get a confirmation since I read breaking inheritance in experience fragments is an option only from AEM 6.4.

Thanks,

Sudha.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

15 replies

Level 2
Nov 20, 2018 5:28 AM UTC

Sorry I lost this thread.

Hero - AEM content component with Sling model

Panel1- Content Fragment

Panel2 - Content Fragment

is there anyway by which Panel1 and Panel2 paths be added to hero component? Such that Hero component Sling model can read data from these content fragments and construct the JSON?

Is this possible?

Translate
New Participant
Jul 17, 2018 12:17 AM UTC

Are you saying that panel can be a content fragment

Hero component- with sling model can read the panel JCR data?

How do I associate Hero component with Panel Content frgamnet path?

Both are 2 independent components on the same page?

Translate
smacdonald2008
Level 10
Jul 17, 2018 12:14 AM UTC

Hero sling model - provided you have used Java code - can read the JCR via the JCR API or QUeryBuilder API.

Translate
New Participant
Jul 16, 2018 11:13 PM UTC

Anyone tries content fragments?

Pointers would really help.

Translate
Level 2
Jul 11, 2018 12:32 AM UTC

Okay so what I am getting is:

Experience fragments is a group of AEM components.

I cannot associate Experience fragment as such with any sling model like I do for AEM content component.

This is noted.

How about Content fragments?

1. I have a content fragment - panel1, created backed by content fragment model

2. On home.html I will have Hero component and COntent Fragment component.

3. Content Fragmnet component will browse for panel1

4. Is there any way Hero sling model can read panel1? Or panle1 path can be fed into Hero component?

Translate
smacdonald2008
Level 10
Jul 10, 2018 6:09 PM UTC

Experience Fragments are simply a collection of other AEM components (that can be named) and the AEM Components can be dropped onto the Experience Fragment ( like a components can be dropped onto a page).

If you need to query the JCR and pull that data and display the data on the front end  - you can write a HTL/Sling Model component that queries data and displays it. Name that component myHTL. THen you can drop that component into an Experience Fragment (If you want) or directly onto page.

Translate
smacdonald2008
Level 10
Jul 10, 2018 4:36 PM UTC

Purhaps you should look at writing an HTL component that uses Sling Models and HTL code as opposed to Experience Fragments. Experience Fragments are not meant to read Java code like HTL components are.

Translate
Level 2
Jul 10, 2018 4:12 PM UTC

Using experience fragments - No I am not getting. I am not sure how I use experience fragments in this use-case. Thats the #1 under issues that I described.

I have my home.html -> I added Hero component and 2 Experience Fragment Component. Each of the experience fragment components has the panel information which needs to be read in SLing Model of Hero.

How can I do that?

Translate
smacdonald2008
Level 10
Jul 10, 2018 3:40 PM UTC

Using the SLing API, are you getting the result set you need?

Translate
Level 2
Jul 10, 2018 3:13 PM UTC

Sling API

Translate