We wants to know how can we display latest things based on date using services and filters on website.
Solved! Go to Solution.
Views
Replies
Total Likes
Could you please explain your requirement here. What are the latest things?
Could you please explain your requirement here. What are the latest things?
we want to display latest news in our home page. so how can we achieve that
Please provide your input on below queries -
1. What is the source for news data/content in your project?
2. Are you consuming any 3rd party api to get the news or content authors are adding news on your site using component on daily basis?
3. In case of 3rd party API are you getting json data associated with news?
4. Are you planning to display only top 5 latest news on home image?
1. This project is just like assignment where we are not holding any real time data.
Temporarily We have created content fragment and its variations to add news data. Content fragment consists news posted date, news heading, news description.
As you said a content author can add the news on daily basis how can we achieve that?
3. we are not using any 3rd party API.
4.We are planning to display only top 5 latest news on home page.
Steps are given below -
1. I am assuming that you have organized all the news specific content fragments inside a folder like the below one -
2. Authors are adding news on daily basis using content fragments here.
Let's assume that you want to retrieve/read top 5 news specific content fragments based on created datetime. In that we could use below query -
path=/content/dam/we-retail/en/faqs/orders type=dam:Asset 1_property=jcr:content/contentFragment 1_property.value=true
2_daterange.property=jcr:content/cq:lastReplicationAction
2_property.value=Activate orderby=@jcr:created p.limit=5
3. This query will be part of your custom OSGi service and this service will be return a list with News title [Assuming that each content fragment is representing individual news].
4. Next you need to invoke the above mentioned OSGi service either via Sling model or directly from htl code. You can create a separate component like News Article component.
Your htl code will be part of this News Article component.
5. You need to iterate that list as mentioned in step-3 and display the result on homepage via News Article component.
Please note that we aren't supposed to advice content authors to publish home page every time after creating news specific content fragments and publish.
Then question may arise how will we deliver updated news list on home page as we do have caching.
In that case we could leverage Sling Dynamic include for News Article component to deliver latest top 5 news.
Thank you so much sir, will try the solution and get back to you if any queries arise
Views
Likes
Replies
Views
Likes
Replies