Forum Discussion

tripp-bishop's avatar
11 years ago

Customize date format of messge-list OOB component

Hi guys,

 

Is there anyway to customize the date format used in the "Latest Post" column of the message-list of the component? I know that I can choose a format from the Admin plugin but I need a format not available in that radio group. Will I have to create a custom component that replaces the message-list to achieve this or is there an simpler way to go about it?

Cheers,


Tripp

  • NicoB's avatar
    NicoB
    Lithium Alumni (Retired)

    Hi tripp-bishop 

    I'm afraid but if the proposed date formats available in the admin console don't suit your need, you have to get in touch with Lithium professional services to allow you to customize the Latest Post column so that you will be able build any date format you need.

    Currently there is no way to customize the content of a message list without Lithium Professional Services engagement.

     

    Thanks,

     

    Nico

    • I suspected that this was the answer but thought that I'd ask anyways just in case there was something easy I was missing.

      • jferrandis's avatar
        jferrandis
        Expert

        Hi

         

        You can make a custom component to control the date format. It's some quite easy develpment. 

         

        tips: use the context to get the message

         

        example:

        <#-- check if you are in a message context -->
        <#if env.context.message.uniqueId??>
        <#-- make your query -->
        <#assign postTimeDataQuery = rest("2.0","/search?q=" + "SELECT post_time FROM messages WHERE id = '${env.context.message.uniqueId?c}'"?url) />
        
        <#if postTimeDataQuery.status =="success" && postTimeDataQuery.data.size gt 0  ><#-- make sure you have some result -->
        <#-- now you can format date --> 
        <#assign myFormattedDate = postTimeDataQuery.data.items[0].post_time?myCustomFormat
        <span class="foo"><${myFormattedDate}</span>
        
        </#if>
        
        </#if>

        Here is the available builts-in for date in freemarker