Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
Link an attachment of a knowledge base entry via an ADT
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
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-->