dustin
9 years agoExpert
How do I get message id from Post Page?
On the Post Page, I would like to display a message based on the topic's age.
To do this, I first need to retrieve the ID of the topic message that is being replied to. The following didn't yield any results...
<#if page.context.thread??> <div>topicMessage: ${page.context.thread.topicMessage.uniqueId}</div> </#if> <#if page.context.message??> <div>message: ${page.context.message.uniqueId}</div> </#if>
How should I be retrieving the topic message ID from the Post Page?
Because the message context object is not available on the post page, I found that you need to resort to other methods.
The solution I implmented was to parse the request url with freemarker to grab both the board ID and message ID.
Here is the freemarker code...
<#assign boardKey = "board-id"> <#assign messageKey = "message-id"> <#assign urlString = http.request.url> <#assign strCount = 0> <#list urlString?split("/") as subStr> <#if messagePos?? && strCount == messagePos> <#assign messageID = subStr> </#if> <#if boardPos?? && strCount == boardPos> <#assign boardID = subStr> </#if> <#assign strCount = strCount + 1> <#if subStr == boardKey> <#assign boardPos = strCount> </#if> <#if subStr == messageKey> <#assign messagePos = strCount> </#if> </#list> <#if boardID??> <div>Board ID: ${boardID}</div> </#if> <#if messageID??> <div>Message ID: ${messageID}</div> </#if>