so I wanna display the "last updated on" base on the changes made to the content (excluding header/footer).
Any ideas how this can be done? on our AEM, the header and footer is a separate component and I should like to display the "last updated on" on the footer.
I've searched the net but didn't see anything useful.
Thanks!
Solved! Go to Solution.
Hi,
What do you mean by above statement. Do you want to show it on footer html ?
If you are trying to read the last modified date of footer node. Just add the below code in your footer component:
Last Updated on ${'dd-MM-yyyy' @ format=properties['jcr:lastModified']}
(or)Last Updated on ${'dd-MM-yyyy HH:mm' @ format=properties['jcr:lastModified'], timezone='GMT+05:30'}
Go through this link as well : htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub
Update:
The above code works on 6.3 but not on 6.2 .
You can do as below:
package com.project;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.adobe.cq.sightly.WCMUsePojo;
public class DateFormatter extends WCMUsePojo {
private String formattedDate;
@Override
public void activate() {
Calendar date = get("date", Calendar.class);
String format = get("format",String.class);
SimpleDateFormat formatter = new SimpleDateFormat(format);
formattedDate = formatter.format(date.getTime());
}
public String getFormattedDate() {
return formattedDate;
}
}
<sly data-sly-use.date="${'com.project.DateFormatter' @ date=properties['jcr:lastModified'],format='dd/MM/yyyy'}">
${date.formattedDate}
</sly>
Hi,
What do you mean by above statement. Do you want to show it on footer html ?
If you are trying to read the last modified date of footer node. Just add the below code in your footer component:
Last Updated on ${'dd-MM-yyyy' @ format=properties['jcr:lastModified']}
(or)Last Updated on ${'dd-MM-yyyy HH:mm' @ format=properties['jcr:lastModified'], timezone='GMT+05:30'}
Go through this link as well : htl-spec/SPECIFICATION.md at master · Adobe-Marketing-Cloud/htl-spec · GitHub
Update:
The above code works on 6.3 but not on 6.2 .
You can do as below:
package com.project;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.adobe.cq.sightly.WCMUsePojo;
public class DateFormatter extends WCMUsePojo {
private String formattedDate;
@Override
public void activate() {
Calendar date = get("date", Calendar.class);
String format = get("format",String.class);
SimpleDateFormat formatter = new SimpleDateFormat(format);
formattedDate = formatter.format(date.getTime());
}
public String getFormattedDate() {
return formattedDate;
}
}
<sly data-sly-use.date="${'com.project.DateFormatter' @ date=properties['jcr:lastModified'],format='dd/MM/yyyy'}">
${date.formattedDate}
</sly>
Hi Susheel,
I want to display the last modified date of page in which i put this footer node.Please let me know
Views
Replies
Total Likes
You would implement a HTL component using Java WCMUSEPOJO and obtain this node property using Java code. Then display the value via HTL - as explained the correct response of this thread.
Views
Replies
Total Likes
How to obtain node property in java? The above code displays the footer node last modified date. But i need the page last modified date
Views
Replies
Total Likes
Hi,
You can use Node Property like below.
String nodePath = "/content/community-components/en/comments/jcr:content/content/title";
try
{
Node node = null;
NodeIterator nodes =null;
String result="";
resource = slingRequest.getResourceResolver().getResource(nodePath);
if(resource != null)
{
node = resource.adaptTo(Node.class);
if(node.hasProperty("jcr:lastModifiedBy"))
{
result=node.getProperty("jcr:lastModifiedBy").getValue().getString();
out.print(result);
}
}
}
catch(Exception e)
{
out.print(e);
}
Regards
Manikantha R
Views
Replies
Total Likes