How do I add the date in a forum thread list overview (on the right side).

Hello, as described in the subject, I want to add the date the post is created to the forum thread list.

If that is not possible, how do I add the date/timestamp of the latest reply/update in the overview of the forum threads?

Or can I add both the date the post is created AND the timestamp (of x hours/day/years ago) of the latest reply/update in the overview of the forum threads?

Parents
  • Hi Irene,

    Yes, this is all doable with a little coding knowledeg. You will need to edit the widget via Administration > Interface > Widget Studio. Find the "Forum - Thread List" widget, "list.vm" file. There you'll see references to a $thread object, and can reference the API documentation, specifically the ForumThread type, for available properties. Many other things can be done with the API for information that is not included in the thread object itself.

    Note that if you are on 9.x, it's considered a legacy version.  Later versions of the widget (for example, the one used in this forum) may already have some of the details that you want to add.

  • Thank you Steven. How can I see what version of the widget I have? I can only see the following options in the list.vm when I enter $ .: 'LatestReplyAuthorID', 'LatestURL', LatestUser and LatestFormat, so not the 'LatestPostDate' I am looking for. 

  • Is your current version of the Thread List widget customized? If so, it would identify this in Widget Studio with a yellow "Customized" flag. Next to the flag you can view the default version as well as compare and/or revert portions of it.

    The default version of this widget for 9.x should already include the latest reply date within this following block:

    <div class="minimal cell nowrap latest">
    	#set ($latestReplyAuthorId = false)
    	#set ($latestReplyAuthorId = $thread.LatestForumReplyAuthorId)
    	#set ($isStarter = false)
    	#set ($latestUrl = $thread.Url)
    	#if ($latestReplyAuthorId && $latestReplyAuthorId > 0)
    		#set ($latestUser = $core_v2_user.Get("%{Id = $latestReplyAuthorId }"))
    		#set ($latestUrl = $core_v2_forumUrls.ForumReply($thread.LatestForumReplyId))
    	#else
    		#set ($isStarter = true)
    		#set ($latestUser = $thread.Author)
    	#end
    
    	#if ($isStarter)
    		#set ($latestFormat = $core_v2_language.GetResource('StartedFormat'))
    	#else
    		#set ($latestFormat = $core_v2_language.GetResource('LatestReplyFormat'))
    	#end
    
    	$core_v2_language.FormatString($latestFormat, $core_v2_encoding.HtmlAttributeEncode($latestUrl), $core_v2_language.FormatAgoDate($thread.LatestPostDate, false), $core_v2_encoding.HtmlAttributeEncode($latestUser.ProfileUrl), $latestUser.DisplayName)
    </div>

    Specifically, it creates a cell in the table that would render a caption including the name of the latest reply author and when they replied. However, if you only wanted to render the date, the following line does that with a live-updating "ago" format.

    $core_v2_language.FormatAgoDate($thread.LatestPostDate, false)

    Other date formats are available within the $core_v2_language API as well.

  • Hello, thank you. Both the default and the current (customized) version have 'StartedFormat' . In addition, I added 'false' after the LatestPostDate as you explained ($core_v2_language.FormatAgoDate($thread.LatestPostDate, false)

    But nothing has changed... 

    What can it be?

Reply Children