two different components with the same path on the same page | Community
Skip to main content
October 16, 2015
Solved

two different components with the same path on the same page

  • October 16, 2015
  • 3 replies
  • 1268 views

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

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

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

3 replies

smacdonald2008
Level 10
October 16, 2015

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.

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

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

October 16, 2015

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