Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

sightly || not able to fetch "cq:lastReplicated"

Avatar

Level 4
The following is not working in sightly
  • ${properties.cq:lastReplicated} / ${pageProperties.cq:lastReplicated}

But I am able to retrieve the other custom and OOTB jcr properties like ${pageProperties.jcr:title}

Is there a different mechanism to fetch the 'cq:' properties  ?

/Regards
Kanwal

1 Accepted Solution

Avatar

Correct answer by
Employee
7 Replies

Avatar

Employee

to this is likely because it is a date-field.

can you try ${properties.cq:lastReplicated.toString}

Avatar

Level 2

Hi Feike,

doing ${properties.cq:lastreplicated.toString} prints the GregorianCalendar object as string. 

java.util.GregorianCalendar[time=1438916511961,areFieldsSet=true,areAllFieldsSet=true,lenient=false,zone=sun.util.calendar.ZoneInfo[id="GMT+10:00

I was looking to get the date string only. Tried ${properties.cq:lastreplicated.getString} and ${properties.cq:lastreplicated.string} but both didn't work. 

Thanks, 

Deepak

Avatar

Correct answer by
Employee

Avatar

Level 3

@Deepak,

This code may help you. 

package com.mycompany.aem.slighty;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import com.adobe.cq.sightly.WCMUse; 

public class Info extends WCMUse {
       
    public String finalDate;
    String tempDate;
    String[] dateTemp;
    Map<String,String> tempMap=new HashMap<String, String>();
        
    @Override
    public void activate() throws Exception {
        
        tempDate=getProperties().get("jcr:created").toString();        
        dateTemp=tempDate.split(",");         
        for(int i=0;i< dateTemp.length;i++){
            String[] temp=dateTemp[i].split("=");            
            tempMap.put(temp[0], temp[1]); 
        }
        finalDate=tempMap.get("DAY_OF_MONTH")+":"+tempMap.get("MONTH")+":"+tempMap.get("YEAR");             
    }    
    public String getFinalDate(){
        return finalDate;
    }

}

 

You can put this java file  along with your component html and can call to this info class as below.

<div  data-sly-use.info="Info">
    <h3>original value is : ${properties.jcr:created.toString}</h3>
    </br>
    <h4>final value is : ${info.finalDate}</h4>

</div>  

 

 

Thanks,

Shivamurthy MN

Avatar

Level 2

Hi,

This doesn't work either.

<sly data-sly-use.util="${'util.js' @ date=currentPage.lastModified.time, mask='dd MMMM yyyy'}"> --- this works. But I couldn't get something similar for cq:lastReplicated value.

Could you please direct me to some article which specifies the list of properties allowed with 'currentPage' convenience object?

Regards,

Bhavya S

Avatar

Community Advisor

Hi,

Last Replicated at  ${'MM/dd/yyyy HH:mma' @ format=pageProperties.cq:lastReplicated } will work

and to get the details of all HTL global object and their API's you can check below:

HTL Global Objects

Thanks

Arun



Arun Patidar

Avatar

Level 1

Hi,

I need date format as "August 17, 2022". Is it possible? 

Also, the link  http://blogs.adobe.com/experiencedelivers/experience-management/date-formatting-sightly/ is not working.

 

Regards,

Priyanshi