Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

two different components with the same path on the same page

Avatar

Former Community Member

Hi all

i have a bit of an odd problem.
We like to include two different components (both having an EditBar) on the same page, both using the same resource path:

<cq:include path="header" resourceType="/apps/header" /> <cq:include path="header" resourceType="/apps/title" />

We're already live with our page where there is only one component and all data is stored in the "header" node. Now the customer wants to split it in two components, but the data that was already entered should still be available and editable.

When I test the page in the browser, i have following results:
The content of both components are displayed on the rendered page, but the EditBar of the second component is missing.

I've analysed the WCM JavaScript code and figured out, that the resource path is used as identifier of the EditBar. Therefore, as i have used the same path twice, only one EditBar will be created.

Is there any way I can have two components with the same path on the same page?
Or any other suggestions to approach this task?

Thanks in advance and best regards

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

Two component sharing the very same resource is bad practice. What you see is probably only one downside of it.
I would suggest that you write a small service, which splits the original header node into 2 nodes, one for each component. It shouldn't be that hard, as the logic should be straight foward

kind regards,
Jörg

View solution in original post

3 Replies

Avatar

Level 10

I have found it works better when a component has its own path - that is each component has a unique path.  Say:

app1/components/component1

app1/components/component2

Each component in this example is unique and has a different path. There will be no conflicts.

Avatar

Correct answer by
Employee Advisor

Hi,

Two component sharing the very same resource is bad practice. What you see is probably only one downside of it.
I would suggest that you write a small service, which splits the original header node into 2 nodes, one for each component. It shouldn't be that hard, as the logic should be straight foward

kind regards,
Jörg

Avatar

Former Community Member

thanks for your answers.

i feared that my previous approach is bad practice, thanks for confirmation.
so i will check your suggestions and hopefully find a solution :)

the service approach sounds reasonable to me, even though we think it is a bit risky do this kind of data manipulation on an already running system, as we might have to change other components which use the existing data.

best regards
patrick