Forum Discussion

bhupen's avatar
bhupen
Advisor
10 years ago
Solved

how to get post_time?

Hi guyz,

I have got post title and author login but Iam not able to get the post time. Can any body help me in this:

following is the api i used:

http://community.lithium.com/restapi/vc/search/messages?q=is_root:true&sort_by=-replies

<#list messages.data.items as recent >

I used title using this syntax:  ${recent.subject}

Author:${recent.author.login}

</#list>

 

but when I am trying to get post date at this way : ${post_time} its giving me error that "Can't convert the date to string, because it's not known which parts of the date variable are in use.

 

Thanks

  • bhupen 

     

    You're developing lots of widgets !

    Try this one, worked for me:

     

    <div class="recent_digital_platform">
    <h3>Trending Topics</h3>
    <#setting locale="en_US">
    <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE replies.count(*)>0 AND depth=0 order by replies.count(*) desc LIMIT 3"?url) />
    <#if messages.data.items??>
      <#list messages.data.items as recent >
        <#if recent?has_content>
          <a href="${recent.view_href}">${recent.subject}</a>
          <span>${recent.author.login}</span>
          <span>${recent.post_time?datetime}</span>
          <br/>
        <#else>
          No post Trending Topics found.
        </#if>
      </#list>
    </#if>
    </div>

     

    2015-02-06_0923.png

6 Replies

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    VarunGrazitti  Thanks for reply

    following is the code. Iam using API V2:

    <div class="recent_digital_platform">
    <h3>Trending Topics</h3>
    <#setting locale="en_US">
    <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE replies.count(*)>0 AND depth=0 order by replies.count(*) desc LIMIT 3"?url) />

        <#if messages.data.items?datetime>                
            <#list messages.data.items as recent >
                <#if recent?has_content>
            <a href="${recent.view_href}">${recent.subject}</a>
        <span>${recent.author.login}</span>
        <br/>
        <#else>
        No post Trending Topics found.
    </#if>
    </#list>
    </#if>
    </div>

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    bhupen 

     

    You're developing lots of widgets !

    Try this one, worked for me:

     

    <div class="recent_digital_platform">
    <h3>Trending Topics</h3>
    <#setting locale="en_US">
    <#assign messages = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE replies.count(*)>0 AND depth=0 order by replies.count(*) desc LIMIT 3"?url) />
    <#if messages.data.items??>
      <#list messages.data.items as recent >
        <#if recent?has_content>
          <a href="${recent.view_href}">${recent.subject}</a>
          <span>${recent.author.login}</span>
          <span>${recent.post_time?datetime}</span>
          <br/>
        <#else>
          No post Trending Topics found.
        </#if>
      </#list>
    </#if>
    </div>

     

    2015-02-06_0923.png

  • bhupen's avatar
    bhupen
    Advisor
    10 years ago

    OlivierS  Thanks, you alwyz helped me a lot. This worked for me but I have one more query inside it. Is it possible to show the posts only for one day(current day)?

     

    Can we make any check using with following date. So that we can show only current day posts?

     

    ${recent.post_time?datetime}

     

    After that I'll mark your above reply as solution

  • bhupen - your query has already been answered, you should already have marked it a solution, this is another query you're putting in.
  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)
    10 years ago

    bhupen 

     

    I will second VarunGrazitti on this one. Try to post one question per thread. It makes it much easier! Thanks :-)