Inactive User
6 years agoUrl has one id, page.context.message.id is a different ID??
When I use the API browser for the URL id, t5/Discussions/How-about-a-Jelly-baby/m-p/7973 [id: 7973], I get the correct results I'm looking for. However, when I use page.context.message.id => '272', which is a completely different message! What's going on here, any ideas before I open a support ticket? Are there IDs and Unique IDs and are they getting mixed up?
I'm trying to get the ID to look up the cover_image and images array for an Open Graph component. But failing because of this.
Ian
<#-- OPEN GRAPH -->
<#macro setOGProps msgs imgs>
<#if msgs?? && msgs[0].cover_image??>
<!-- msgs cover image OK -->
<#assign ogImgUrl=msgs[0].cover_image.large_href />
<#else>
<#if images??>
<!-- images exist? ${images???c} -->
<!-- images size ${images?size} -->
<#if images?size gt 0>
<!-- images size ${images?size} -->
<#assign ogImgUrl=images[0].large_href />
<#else>
<#assign ogImgUrl="https://www.jmp.com/content/dam/jmp/media/JMP-Open-Graph-Default.jpg"/>
</#if>
<!-- default cover image -->
</#if>
</#if>
<!-- OPEN GRAPH CONTENT -->
<meta property = "og:title" content = "${page.content.body.title}"/>
<meta property = "og:image" content = "${ogImgUrl}"/>
<meta property = "og:url" content = "${msgs[0].view_href}"/>
<meta property = "og:description" content = "${msgs[0].subject}"/>
<meta property = ”og:type” content = ”website”/>
</#macro>
<#if env.context.message??>
<!-- env.context.message -->
<!-- env.context.message.id ${page.context.message.id} -->
<#assign msgQuery = "SELECT cover_image, view_href, subject FROM messages WHERE id='${env.context.message.id}'"/>
<#assign msgs = rest("2.0", "/search?q=" + msgQuery?url + "&restapi.response_style=view").data.items![] />
<#assign imgQuery = "SELECT view_href, title FROM images WHERE messages.id='${env.context.message.id}'"/>
<#assign images = rest("2.0", "/search?q=" + imgQuery?url + "&restapi.response_style=view").data.items![] />
<#--<p>${images?size}</p>-->
<@setOGProps msgs=msgs imgs=images></@setOGProps>
</#if>
<#if page.context.message??>
<!-- page context message -->
<#--<!-- page.context.thread.topicMessage.id ${page.context.thread.topicMessage.id} –>-->
<!-- page.context.message.id ${page.context.message.id} -->
<#assign threadQuery = "SELECT cover_image, view_href, subject FROM messages WHERE id='${page.context.message.id}'"/>
<#assign msgs = rest("2.0", "/search?q=" + threadQuery?url + "&restapi.response_style=view").data.items![] />
<#assign imgQuery = "SELECT view_href, title FROM images WHERE messages.id='${page.context.message.id}'"/>
<#assign images = rest("2.0", "/search?q=" + imgQuery?url + "&restapi.response_style=view").data.items![] />
<#--<p>${images?size}</p>-->
<@setOGProps msgs=msgs imgs=images></@setOGProps>
</#if>
Hi Inactive User ,
Try "uniqueId" instead of "id".
The "uniqueId" is a community-wide unique message id and corresponds to what you're seeing in the URL. The "id" is a board-specific message id.