Forum Discussion

Fellsteruk's avatar
10 years ago

Displaying Custom component if topic age is greater then X...

Hey Guys, 

 

I have an idea I want to execute where we display a message on the top of a thread/topic if the age of the topic is greater than X. In theory I'm thinking of a custom component which i will place on the topic page layout and "somehow" using code display the component if the age of the topic is great than X.

 

We do something similar around a founders badge which is displayed if a user has a certain role but im not sure how to achieve this based on the age of a topic, does anyone have any code or pointers they could share on this.

 

Thanks 

  • Hi Stephen,

     

    You would need to add a custom component on the Forum Topic Page that does the following:

    1. Get the topic ID for the currently shown message:
      SELECT topic.id FROM messages WHERE id = '${coreNode.nodeId}'
      because user might access a topic through a deepd message link and you want to pull the timestamp for the topic opening message.
    2. With the topic.id you can then pull the post_time:
      SELECT post_time FROM messages WHERE id = '${topicId}'

    The only challenge here is that post_time is a date string a la "2014-10-23T05:10:05.331-07:00" which can't be compared easily :(

     

    Anyone from Lithium knows if we can pull the post_time in Long format representing the milliseconds similar to the solution for comparing timestamps here?