Reputation: 1217
I usually use <cq:include path="fakepath" resourceType="/project/components/testcomponent" />
to include a component inside a another component, named it as "setComponent".
Assume, "setComponent" drag and dropped onto a page and no data entered yet.
Question 1:
First thing is the "testcomponent" resource does not exist at the /content tree page level and I see GET request to "fakepath.infinity.json" when I double click "testcomponent" to enter data, and this GET request is failing (404 error in browser developer tool console). Not sure, whether it is expected behavior.
Question 2:
How can I include component "/apps/project/components/testcomponent" inside a parent component using below tags ?
<sling:include path="" />
<sling:include resource="" />
<sling:include path="" resourceType="" />
I am educating myself to properly understand and trying to see if sling:include could get rid of 404 error that I am talking.
Thank you, Sri
<%@include file="/libs/foundation/global.jsp"%>
<div>
<cq:include path="navMenu"
resourceType="sampleproj/components/common/testMenu" />
</div>
pseudocode for testMenu jsp:
<%@page session="false"%>
<%@include file="/libs/foundation/global.jsp"%>
<%@ page import="com.day.cq.commons.Doctype,
com.day.cq.wcm.api.PageFilter,
com.day.cq.wcm.foundation.Navigation" %>
<ul class="nav">
<li><a href='navitempath.html'><div>navitemtitle</div></a></li>
</ul>
Upvotes: 0
Views: 5661
Reputation: 11
If you use sling:include you are loading an existing node from other path.
For example :
<sling:include path="./mycomponentpath" resourceType="/apps/company/components/componentName"/>
mycomponentpath is a node created previously, and you are injecting this content in your actual component.
You can use <cq:include path="fakepath" resourceType="/project/components/testcomponent" />
if you want include and empty component within other component.
I need more information to help you. Could you copy the testcomponent jsp ?
Upvotes: 1
Reputation: 865
Try to remove extra '/' symbol from resourceType
<cq:include path="fakepath" resourceType="project/components/testcomponent" />
Upvotes: 1