Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Building an external HTML page from content stored in CQ

Avatar

Level 3

Hi All

CQ version 5.6

I have the following scenario. Content is authored and stored in my CQ instance.

Site A is using CQ and http://myUnsecuredSite/home/myCQPage.html will be deleivered by CQ. Straight forward scenario here

Now here is where things start getting a little bit complex

I want on my secure site “Site B” for page https://mySecuredSite/home/notCQPage.html to be able to display the content of the body of myCQPage.html. Only the header and the footer are different the rest of the content will be the same. This site will not be build in CQ

The question is how do I build my notCQPage.html with content stored in my CQ site ( site A) ? I also need to make sure that the header and footer is visually the only difference between myCQPage.html and notCQPage.html

Any guidance or suggestion is much appreciated

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

I would provide a "includecontent.jsp" on the template level, which just renders the body of the page, omitting the headers and footers. Then you can do a HTTP request to http://myUnsecuredSite/home/myCQPage.includecontent.html in your non-AEM application and insert the content there. I would place a dispatcher in front of the AEM instance to have these requests cached, which will save you lot of latency.

Jörg

View solution in original post

5 Replies

Avatar

Level 10

Hi,

Couple of ways here.

1. Directly do a JCR query to the page node and read the necessary parsys from 'Site B'

2. You can get json response and parse the content what you need.

Avatar

Correct answer by
Employee Advisor

Hi,

I would provide a "includecontent.jsp" on the template level, which just renders the body of the page, omitting the headers and footers. Then you can do a HTTP request to http://myUnsecuredSite/home/myCQPage.includecontent.html in your non-AEM application and insert the content there. I would place a dispatcher in front of the AEM instance to have these requests cached, which will save you lot of latency.

Jörg

Avatar

Level 10

As bsloki points out - you can get the HTML for a page located here:

[img]partext.png[/img]

Avatar

Level 3

Thanks gents for the response

Can my "Site B" get the HTML live from the CQ repository i.e. by making an AJAX call to CQ sling servlet, or the latency will be too long to try and render the CQ content on page load of "Site B"

The other alternatives i guess will be 

1) CQ custom service to push published content(JSON/XML) on replication. My "site B" picks up the JSON of the newly published content from i.e. a relational database, or filesystem

2)  pull the published CQ content at certain intervals. The pulled content(JSON) is parsed and stored in a relational database. "Site B" is rendering content from the relational database

Any suggestion on which proposal could work?

Avatar

Level 10

YOu can code a servlet to host in Site A. Then invoke it from the other site. The servlet can return JSON data after reading the JCR. However - this would be a custom servlet - it's not an outof the box feature.