Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

How to reuse component on another page?

Avatar

Level 2

Hello

I have a component filled with the same data and would like to use it on other pages in the website.  How can this be done?  Rather than recreate this component over and over again 100 times and adding the same data 100 times. 

I tried copy but will not paste on another web page.

Thank you for your help!

15 Replies

Avatar

Level 10

Typically a component on a page has its own data that is separate from other instances of the same component on other pages. For example, if you have an image component - although its the same image component (same sling resource type) - each instance shows a  different image.

Avatar

Level 2

Then does Adobe have a query component to access a database or xml file?

Avatar

Level 10

Adobe Provides the APIs to let you write your own component to access a database. For example, to access MySQL, you use a DataSourcePool and configure it. Then you can use it to query data from MySQL and display the data in a page. We have a developer artilce that shows you how to use the DataSourcePool API:

Scott's Digital Community: Injecting a DataSourcePool Service into an Adobe Experience Manager OSGi ...

YOu can watch a video too.

Avatar

Employee Advisor

If you want to do content-reuse within a page, this should be carefully planned. There are a lot of different ways how you can achieve this, but each one has pro's and con's, and without knowing much more details about your usecase it doesn't make sense to go into details.

To name some ways to reuse content, let me list some from the top of my head:

  • iparsys
  • reference component
  • multisite manager (MSM)

The decision which one to use is driven by the (content) architecture of your application/site. From my point of view it should never be the decision of a developer which approach to use!

Jörg

Avatar

Level 2

I did not mark Jorg Hoh as the correct answer. 

The decision can be from a developer or designer!

Avatar

Employee Advisor

Hi,

Of course a designer or a developer can make that decision, but in most cases a designer or a developer does not see all the consequences coming from that decision.

For example, are you aware of the consequences of using the MSM to achieve content reuse? It has impact on the authoring process as a whole, because authors now suddenly need to break inheritance to change a page. And enable inheritance to get the latest changes. If you use a kind of freestyle-MSM (neither planned nor managed usage of it) your authoring process will be unmanaged too, because noone understands easily what impact a rollout might have.

Then about the different rollout options, which will have a huge impact too. Not to talk about the resulting system load.

Same with iparsys or reference component.

Content reuse is an essential part of the information architecture and your business domain. I think that any decision and change here should made with care.

Avatar

Level 10

We marked Joerg's answer as correct as he provided an excellent response that addresses this question.

Avatar

Level 2

Hi there,

We have to agree to disagree and move on. 

Avatar

Level 2

So if you have a component like a -dropped down selector- listing all of the United States- for the user to choose from… you are basically stating here that it can't be done other than what I suggest is to created db or xml file.

Just wanted to be sure we are all on the same page here with my question.

Thanks again for your feedback!

Avatar

Level 2

If anyone can contribute or help with an example to my question or point me to a third party tool that would be great!

Right now, the requests I'm getting are totally not realistic because people making the decisions are not certified or have the technical background to know any better.

Thanks to all who have given there time to this question.

Avatar

Level 10

Its unfortunate that you consider Joerg answer as not correct as he is one of the top AEM ppl within this community. He mentioned MSM and Kautuk mentioned Content Fragments - both of which are meant to help with re-use of content.

Of course you can go back to basics and have authors drag and drop and components onto the parsys and edit the components - which is typically the job of an AEM author and the way AEM works at the basic level. 

Avatar

Employee Advisor

Hi,

I appreciate your opinion and accept that you still want to pursue your approach. I am OK with that, because I still do not understand your situation completly. I tried to give you some ideas why I think your approach will cause problems, but it's okay that you won't accept it. No problem.

The easiest way to do it is likely the reference component. At each place you want to reuse the content add the reference component and point it to the original location. If you already have a component at the places, where the to-be-reused content has to appear and you cannot replace it, I don't think that there is a good solution available then. Then either you do a copy&paste approach or you write a small script (using whatever technology, e.g. shell using curl and the SlingPostServlet ) to automate it.

And to repeat myself: I think that the problem you just have is caused by a design issue.

Jörg

Avatar

Community Advisor

I totally agree with jorg , kautuk , and scott.  I am not sure if you are doing some kind of content migration or a fresh project. If all the above approaches are not acceptable in your case , may be an AEM architect with strong knowledge of the PROS and CONS of each approach can help you to understand this better.

Avatar

Level 2

Regarding the reference component, this approach has been discussed and tested since we don't have control over the design as we would like.

Thank you for your time and contribution!