Expand my Community achievements bar.

SOLVED

How to include an existing component multiple times

Avatar

Level 1

I am going to create a component which needs to reuse the existing component 3 times. In my component's JSP file I added following but getting blank page when creating a template for my component and then creating a page for that template.

<code><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><% %> haha <cq:include path="test" resourceType="/apps/help/components/relatedlinks" /> <cq:include path="test1" resourceType="/apps/help/components/relatedlinks" /> <cq:include path="test2" resourceType="/apps/help/components/relatedlinks" /> </code>
1 Accepted Solution

Avatar

Correct answer by
Employee

Hi,

Are you getting any errors in the error.log file? Does it work when you replace your custom components with OOTB components? 

I just tried the code below and it works as expected:

<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><div class="center">
    <cq:include path="title1" resourceType="foundation/components/title" />
    <cq:include path="title2" resourceType="foundation/components/title" />
    <cq:include path="title3" resourceType="foundation/components/title" />
</div>

View solution in original post

2 Replies

Avatar

Level 10

This should work... are you facing any issues ?

Avatar

Correct answer by
Employee

Hi,

Are you getting any errors in the error.log file? Does it work when you replace your custom components with OOTB components? 

I just tried the code below and it works as expected:

<%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><div class="center">
    <cq:include path="title1" resourceType="foundation/components/title" />
    <cq:include path="title2" resourceType="foundation/components/title" />
    <cq:include path="title3" resourceType="foundation/components/title" />
</div>