Add custom component only to topic post
What condition should one use in FreeMarker so that a costum component only shows up in the topic message post in a forum (the first post that is). I'm having some custom display of tags and was trying to use:
<#assign positionInThread=restadmin("/messages/id/${messageId}/position_in_thread").value>
To check whether it's the first post or not without any luck, since this only gives me the message I've clicked on in the thread.
Example: The first post in a thread has "Everyone's Tags:" but the other messages does not have this.
What I'm looking for is a simple if-statement to put in my costum component.
Thanks!
Hi kjartan You can do this in a better way, the messages in the topic page has IDs specific to them, e.g. this post, the one you opened is accessible via http://community.lithium.com/t5/Developers-Discussion/Add-custom-component-only-to-topic-post/td-p/182500 and http://community.lithium.com/t5/Developers-Discussion/Add-custom-component-only-to-topic-post/m-p/182500
Note the td-p and m-p, these are thread ids and message ids repectively. So, what you can do is get the thread ID and message ID and when these two are equal, you can display your content there. The changes, i.e. your custom compoenent will be placed on the forum message quilt in studio and will only execute when these 2 are equal, which will be your original post.
<#assign threadId = page.context.thread.topicMessage.id /> <#assign messageId = env.context.message.id /> <#if messageId == threadId> //your code goes here, whatever you want to show in the original post. </if>
Let me know if this helps.