DougS
14 years agoKhoros Oracle
Featured thread meta tag (Freemarker)
Description
This component can be used to add a meta tag to the <head> element if the thread being viewed is a featured thread.
Requirements
Lithium version 9.18 or higher, Lithium Studio
How to add this to a Lithium community
There are two parts to adding a meta tag to the head element for featured threads:
- Create a component
- Place the component in the head element
To create the component:
- Go to Studio > Components.
- Click New Component. Enter a name for the component (for example, featured-thread-meta-tag) and click Create.
- Add the following markup to the component:
<#if page.context.thread??> <#assign resp = rest("2.0", "/messages/" + page.context.thread.topicMessage.uniqueId + "?fields=conversation(featured)") /> <#if resp.data.conversation.featured> <meta name="featuredtopic" content="yes" /> </#if> </#if>
4. Click Save.
To place the element in the <head> tag:
- Go to Community Style > Wrapper.
- Copy the following markup into the "Page Head Content" text area:
<#include "featured-thread-meta-tag.ftl" />
3. Click Save.
Example
There is no example page for for this component.
NOTE: This message used to contain the following (REST v1) code snippit, but has been replaced with the REST v2 code above because that is more efficient and concise:
<#if page.context.thread??> <#list rest("/boards/id/${coreNode.id}/threads/featured?page_size=999").threads.thread as thread> <#if thread.messages.topic.id?number == page.context.thread.topicMessage.uniqueId> <meta name="featuredtopic" content="yes" /> <#break /> </#if> </#list> </#if>