Forum Discussion

kjartan's avatar
kjartan
Contributor
11 years ago

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 tryi...
  • VarunGrazitti's avatar
    11 years ago

    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.