cancel
Showing results for 
Search instead for 
Did you mean: 

Get Related Articles of content in web script for atom feed

maithili
Champ in-the-making
Champ in-the-making
Hello,

The View Details of content shows the Related Articles in the Properties section, however if we loop through the properties object the related articles are not listed.
How do we get the document ids of the Related Articles of a document in a web script for an atom feed?
I used the following code from the online documentation.


        <#if !child.isContainer>
            <#– Get a list of all the property names for the document –>
<#assign props = child.properties?keys>
<#list props as t>
    <#– If the property exists –>
    <#if child.properties[t]?exists>
       <#– If it is a date, format it accordingly–>
       <#if child.properties[t]?is_date>
       <dateprop>${t} = ${child.properties[t]?date}</dateprop>
      
       <#– If it is a boolean, format it accordingly–>
       <#elseif child.properties[t]?is_boolean>
       <boolprop>${t} = ${child.properties[t]?string("yes", "no")}</boolprop>
      
       <#– Otherwise treat it as a string –>
       <#else>
       <otherprop>${t} = ${child.properties[t]}</otherprop>
       </#if>
    </#if>
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
Things like "related articles" are implemented using associations. Look at the JavaScript API for association-related properties.

Jeff

maithili
Champ in-the-making
Champ in-the-making
Thank you for pointing in the right direction.


I used the following code to get the information on Related Articles. Kindly let me know if someone finds more information on 'ws' namespace.


<relatedArticles>
   <#if child.assocs["ws:relatedArticles"]?exists>
      <#list child.assocs["ws:relatedArticles"] as t>
         <article>
            <link rel="alternate" href="${absurl(url.serviceContext)}/api/node/content/${t.nodeRef.storeRef.protocol}/${t.nodeRef.storeRef.identifier}/${t.nodeRef.id}/${t.name?url}"/>
            <relID>${t.id}</relID>
            <relTitle>${t.name}</relTitle>
            <relDesc>${t.properties.description}</relDesc>
            <relCreator>${t.properties.creator}</relCreator>
         </article>
      </#list>
   </#if>
</relatedArticles>