如何在liferay中使用freemarker显示平原的html
在Liferay Portal 7.2中,我有Web内容的元素列表。对于此列表中的每个Web内容,我想在Web内容本身中获得HTML结果。
将ADT限制在一个带有默认模板的结构中,以列出它对我工作的每个Web内容:
<#list entries as entry>
<#if hasCategoryId(entry, selectedYearCategoryId) &&
hasCategoryId(entry, selectedTipoNormativaCategoryId)>
<#assign assetRenderer = entry.getAssetRenderer()/>
<#assign journalArticle = assetRenderer.getAssetObject()/>
<@liferay_journal["journal-article"]
articleId=journalArticle.getArticleId()
groupId=journalArticle.getGroupId()/>
</#if>
</#list>
“ HASCATEGORYID”是一个自定义功能,并且此ADT嵌入式需要重新加载整个页面将参数传递到URL中。
我想知道我是否想使用Ajax进行此操作,并在 mvCrenderCommand mvcresourcececommand中进行此操作,它是否存在将Web内容转换为HTML的任何
方法
JournalArticle.getHTML(structureId, templateId);
In Liferay Portal 7.2, I have list of elements that are Web Contents. For each Web Content in this list I want to get the HTML result defined in the web content itself.
Having an ADT restricted to one structure with a default template, to list every Web Content it's working for me:
<#list entries as entry>
<#if hasCategoryId(entry, selectedYearCategoryId) &&
hasCategoryId(entry, selectedTipoNormativaCategoryId)>
<#assign assetRenderer = entry.getAssetRenderer()/>
<#assign journalArticle = assetRenderer.getAssetObject()/>
<@liferay_journal["journal-article"]
articleId=journalArticle.getArticleId()
groupId=journalArticle.getGroupId()/>
</#if>
</#list>
"hasCategoryId" is a custom function and this ADT embedded needs to reload the entire page passing the parameteres to itself in the URL.
I was wondering if I want to do it using Ajax and do this stuff in a MVCRenderCommand MVCResourceCommand, exists any way to convert a Web Content into HTML giving structureId, articleId, ...
Something like:
JournalArticle.getHTML(structureId, templateId);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您正在寻找这种方法,
您可以在 docs 。
当您想使用AJAX调用调用此代码时,您可能应该使用Mvcresourcecommand。代码将是这样的:
我没有测试此代码,所以让我知道Somethig是否错了。
I think you are looking for this method
you can see more about it on the docs.
As you want to call this code with an Ajax call, you should probably be using MVCResourceCommand. The code would be something like this:
I did not test this code, so let me know if somethig is wrong.
如果您要进入Ajax,请使用。您可以轻松获取JSON或HTML的内容。
If you're going into Ajax, use the Headless API. You can easily fetch content as JSON or HTML.
抱歉,我对Ajax和MvCrenderCommand的引用感到有些困惑...
重读您的问题,我建议您简单地将TemplateKey添加到标签调用中,按 https://docs.liferay.com/dxp/dxp/apps/web-experience/7.0.0 .11/taglibdocs/liferay-journal/journal-article.html
类似:
Sorry, I got a bit confused by the references to Ajax and MVCRenderCommand...
Rereading your question I suggest that you simple add a templateKey to your tag invocation, as per https://docs.liferay.com/dxp/apps/web-experience/7.0.11/taglibdocs/liferay-journal/journal-article.html
Something like: