Forum Discussion

iftomkins's avatar
12 years ago

Displaying title of first message of a topic on the topic page?

Happy holidays!

 

We'd like to display the title of the first message of a topic on the topic page. Is there a way to pull the title of the title of the first message (e.g. the original topic title) via the rest API? The goal is to make sure that every single page has the original topic title displayed in full.

 

Here's a screencast showing what I mean: http://screencast.com/t/tuaRYTIbpd0

 

In the screencast, the goal is to always have the title at the top of the topic page say: "Difficulty getting a new Force wrist band on". The current behavior changes the title of the page, because it takes you to the latest unread post on the topic, and makes the title of the page the title of that post. We always want the title on the topic page to be the title of the original post.

 

Thanks!

6 Replies

  • Update:

     

    Here's what I've tried, to no avail. A million error messages as a result. I think I'm on the right track though?

     

    <#assign originalTopicSubject = rest("/messages/id/${page.context.message.id}/root.subject").value>
    ${originalTopicSubject}

     

    Thanks for your help!

    Alan

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi Alan,

     

    I think you're actually really close. Instead of ".../root.subject" try ".../root/subject". For example:

    <#assign originalTopicSubject = rest("/messages/id/${page.context.message.id}/root/subject").value>

     

  • KaelaC's avatar
    KaelaC
    Lithium Alumni (Retired)
    11 years ago
    What's the javascript around this value? If you want to writing out to js rather than html you may need to encode your output. Something like ${originalTopicSubject?html}
  • iftomkins's avatar
    iftomkins
    Maven
    11 years ago

    Here is the code that is in the Desktop Hitbox area:

     

             <#if page.name?lower_case == "forumtopicpage" >
                <#assign originalTopicSubject = rest("/messages/id/${page.context.message.id}/root/subject").value>
                var topicTitle = '${originalTopicSubject}';
                jQuery(".lia-message-subject-banner").each(function(){
                    jQuery(this).text(topicTitle);
                });
             </#if>

     

    And here is the freemarker error response (made some adjustments since last time):

     

    https://www.dropbox.com/s/59dehi42ngfvx33/Screenshot%202014-02-05%2016.08.57.png

     

    thanks so much!