Forum Discussion

jeromedb's avatar
jeromedb
Contributor
12 years ago
Solved

Can I add a last updated or modified date to a page metatag?

Hi guys,

 

I'm working with a sitewide enterprise internal search engine which makes extensive use of custom metadata tags, such as <meta name="product_sku" content="abc123" /> for filtering, categorising, ranking and displaying search results.

 

We intend on indexing category, board, article, blog and thread pages (not messages), and would like to capture the date of the last modification/update to each via a custom metatag added to the page. This will allow us to not only display a "last updated" date within the global search results, but rank content according to recency.

 

So my question is twofold – is the last modified date readily available across category, board, article, blog and thread pages, and if so, can it be added to a metatag such as <meta name="last_updated" content="16-10-2013" />?

 

Much appreciated!

 

Cheers, Jez

  • PaoloT's avatar
    PaoloT
    12 years ago

    Hi Jerome,

     

    as I mentioned you should be able to determine the date of the last change for these pages via the REST API looking at the time elements included in the responses. I am not sure around the effort required in building the XML feed - maybe you could look into the Lithium Studio Endpoints to generate the required data (with the rest calls) and pack it in the response format which can then be consumed by your tool.

     

    I have a feeling that implementing the logic that adds the meta tags directly to the pages may be quicker, but it's difficult to tell without all the details.

     

    In this case - it could be best to speak with your Lithium Manager and see if it's possible to arrange a consultancy on your specific integration issue.

     

    Kind Regards,

16 Replies

  • Thanks Jason - I'll chat with Starhub around the update below and come back to you.

    J

  • jeromedb's avatar
    jeromedb
    Contributor
    12 years ago

     

    Hey Jason,

     

    We've followed the freemarker code example, however we're having some issues dynamically getting the topic id - below is some feedback from the developer that is working across this, would really appreciate any assistance you can provide.

     

    On the timestamp component we're fine.

     

    Cheers, Jez

     

    ---------

     

    the example given in Lithium is this one below, which is throwing an Exception

    <#assign topic_id = page.context.thread.topicMessage.uniqueid />

     

    To test if the rest of the code is working, I hard coded the "topic_id" as below

    <#assign topic_id = 713 />

    and it worked.

     

    But you might notice, it always display the same time. So we need to dynamically get the "topic_id"

     

    Below is the full Code

    <#if page.name='ForumTopicPage'>

    <#assign topic_id = page.context.thread.topicMessage.uniqueid />

    <#assign last_edit_time = restadmin("/messages/id/${topic_id}/last_edit_time").value!"" />

    <meta name = "last_updated" content="${last_edit_time}" >

    </#if>  

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    12 years ago

    Hi Jez,

    My apologies ... typo ...  it should be uid:

     

    <#if page.name='ForumTopicPage'>
    <#assign topic_id = page.context.thread.topicMessage.uid />
    <#assign last_edit_time = restadmin("/messages/id/${topic_id}/last_edit_time").value!"" />
    <meta name = "last_updated" content="${last_edit_time}" >
    </#if>  

     i just tried it out on test env, seems to be working 

  • jeromedb's avatar
    jeromedb
    Contributor
    12 years ago

    Awesome, thanks Jason :)

     

    I've fired off to the dev, will let you know how it goes.

     

    J

  • jeromedb's avatar
    jeromedb
    Contributor
    12 years ago

     

    Hey Jason,

     

    We've successfully deployed a last_updated tag across message pages :)

     

    What I'd like to do now is extend out to cover the other types of pages, such as board and category pages, eg;

     

    http://community.starhub.com/t5/Ask-Kerastase/bd-p/Ask_Kerastase

    http://community.starhub.com/t5/Ask-the-Beauty-Experts/ct-p/Ask_the_Beauty_Experts 

     

    We did it to the "Forum Topic Page" by adding the following snippet in the "Page Head Content";

     

    <#if page.name='ForumTopicPage'>

    <#assign topic_id = page.context.thread.topicMessage.uniqueId />

    <#assign last_edit_time = restadmin("/messages/id/${topic_id}/last_edit_time").value!"" />

    <meta name = "last_updated" content="${last_edit_time}" >

    </#if>

     

     

    We found a list of page.names for Lithium, as follows;

     

    • BlogArticlePage
    • ContestSubmissionPage
    • ForumTopicPage
    • IdeaPage
    • MobileForumTopicPage
    • MobileGroupMessagePage
    • GroupMessagePage
    • CompletedIdeasPage
    • QandAQuestionPage
    • SupportCasePage
    • TkbChooseTemplatePage

     

    To apply the last_updated metatag across alternate pages do we need to only change the page.name to match the correct page type, or do we need to do more?

     

    If we only need to update the page.name, what value do we use for a category (ct-p) and board (bd-p) page?

     

    As a side through, can we cover all types of pages with a single code snippet?

     

    Cheers, Jez

     

  • JasonL's avatar
    JasonL
    Lithium Alumni (Retired)
    12 years ago
    Hi Jerome
    Really sorry, I'm afraid this is getting a little deep and it would be best to engage Lithium Services to scope out the full requirements, properly advise or even implement the freemarker coding.

    Can you kindly ask StarHub to reach out to their Lithium Account Executive for a Services quote?