In AEM 6.3 /apps/core, there is a list component. Try to reuse this component and just overwrite the item.html to make a news listing component.
I have a news component with title, date, content and News.java (using sling models: adaptables = SlingHttpServletRequest.class).
A list component lists all news.
I reuse the list.html, however I have to modify the item.html to retrieve the news node. Don't know how exact to do that.
<sly data-sly-resource="${resource @ appendPath='/jcr:content/root/news'}">
<div class="myproject-news"
data-sly-use.article="myproject.news">
</sly>
<h4 class="myproject-news-title">${ news.title }</h4>
But I am getting an error: org.apache.sling.api.request.RecursionTooDeepException:
Can anyone please help?
Thanks.
Solved! Go to Solution.
When you do
<sly data-sly-resource="${resource @ appendPath='/jcr:content/root/news'}">
looks for all the resources/nodes under your current resource... Depending on where your resource to be rendered is located, you should be using :
<sly data-sly-resource="${resource.path @ appendPath='/jcr:content/root/news'}">
or
<sly data-sly-resource="${currentPage.path @ appendPath='/jcr:content/root/news'}">
Can you try the following?
Change this:
<sly data-sly-resource="${resource @ appendPath='/jcr:content/root/news'}">
to
<sly data-sly-resource="${'root/news' @ resourceType='your resource type'">
You can build news type components too using back end WCMUsePojo and multi field as shown here -- Scott's Digital Community: Creating an Adobe Experience Manager HTL component that displays a repeat...
Views
Replies
Total Likes
Hi ,
I am not able to replicate this exception in your code because this exception is thrown by the Sling implementation if to many recursive content inclusions take place.
Why are you using the list component to make the News Component.you want to display the title,date and content of the news for that either use multifield in dialog and then iterate through the data and display it. Other wise make a simple dialog having three field Title of news(ton), Date of news(datefield), Content(RTE) .At every new news drag and drop the component and fill the data into the dialog and display it for displaying below is the modiified code.
<div class="myproject-news">
<h4 class="myproject-news-title">${properties.title}</h4>
<h3> ${properties.date}</h3>
{properties.content @ context='html'}
</div>
where date = name of date field in dialog (./date)
title =name of title in dialog (./title)
content = name of content (./content)
Thanks
Views
Replies
Total Likes
When you do
<sly data-sly-resource="${resource @ appendPath='/jcr:content/root/news'}">
looks for all the resources/nodes under your current resource... Depending on where your resource to be rendered is located, you should be using :
<sly data-sly-resource="${resource.path @ appendPath='/jcr:content/root/news'}">
or
<sly data-sly-resource="${currentPage.path @ appendPath='/jcr:content/root/news'}">
Views
Likes
Replies