Message Boards
Link an attachment of a knowledge base entry via an ADT
Niels Dohms, modified 3 Years ago.
Link an attachment of a knowledge base entry via an ADT
New Member Posts: 8 Join Date: 12/6/19 Recent Posts
Hello there,
i'm currently writing an ADT to customize the knowledge base style. I'm working with Liferay Portal 7.2.1 CE GA2. As there is not a dedicated ADT version for the knowledge base, i have to use the asset publisher modul and configure it to use only knowledge base assets and to use my custome ADT.
Some of the entries will have a PDF attachment. In the display of these knowledge base entires i would like to link these attachments. There is no obvious link between an knowledge base entry and it's attachment that i can use in an ADT or at least not obvious for me.
Thanks for any tips or help you can give.
Niels
i'm currently writing an ADT to customize the knowledge base style. I'm working with Liferay Portal 7.2.1 CE GA2. As there is not a dedicated ADT version for the knowledge base, i have to use the asset publisher modul and configure it to use only knowledge base assets and to use my custome ADT.
Some of the entries will have a PDF attachment. In the display of these knowledge base entires i would like to link these attachments. There is no obvious link between an knowledge base entry and it's attachment that i can use in an ADT or at least not obvious for me.
Thanks for any tips or help you can give.
Niels
Mohammed Yasin, modified 3 Years ago.
RE: Link an attachment of a knowledge base entry via an ADT
Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts
Hi ,
You can use service locator and use KBArticleLocalservice for fetching the KBArticle and its attachments, you can refer below code snippet
You can use service locator and use KBArticleLocalservice for fetching the KBArticle and its attachments, you can refer below code snippet
<#assign kbArticleLocalService = serviceLocator.findService("com.liferay.knowledge.base.service.KBArticleLocalService") />
<#if entries?has_content>
<#list entries as curEntry>
<#assign kbArticle = kbArticleLocalService.getLatestKBArticle(curEntry.getClassPK(), 0)>
<#assign kbAttachments = kbArticle.getAttachmentsFileEntries()>
<#if kbAttachments?has_content>
<#list kbAttachments as kbAttachment>
${kbAttachment}
<!--#list-->
<!--#if-->
<!--#list-->
<!--#if-->