按类别获取期刊文章:用Python编写的Liferay Portlet [英] Getting journal articles by category: Liferay Portlet written in Python

查看:86
本文介绍了按类别获取期刊文章:用Python编写的Liferay Portlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用Python编写一个简单的Liferay Portlet.该Portlet将显示类别列表,并且在单击时将显示具有特定结构的Web内容文章(期刊文章)列表.

I am trying to write a simple Liferay portlet in Python. The portlet will show a list of categories and when clicked will show a list of Web Content articles (journal articles) of a certain structure.

我能够获取类别列表,但是找不到使用liferay api来按类别获取文章列表的方法吗?

I am able to get the list of categories but cannot find a way using the liferay api to get a list of articles by category?

我搜索了所有内容,但在我看来该方法应该在此页面上:

I have searched allover but it seems to me the method should be on this page:

http://docs. liferay.com/portal/6.1/javadocs/com/liferay/portlet/journal/service/JournalArticleLocalServiceUtil.html

推荐答案

这是Java实现,但转换为python确实很容易.

It is a Java implementation but really easy to convert into python.

<%
String languageId = LanguageUtil.getLanguageId( renderRequest );
List<JournalArticle> journalArticleList = new ArrayList<JournalArticle>();

AssetEntryQuery assetEntryQuery = new AssetEntryQuery();
assetEntryQuery.setAnyCategoryIds(new long[] { 12704 }); //category Id
assetEntryQuery.setOrderByCol1("modifiedDate");
assetEntryQuery.setEnd(5);
List<AssetEntry> assetEntryList = AssetEntryLocalServiceUtil.getEntries(assetEntryQuery);
for (AssetEntry ae : assetEntryList) {
    JournalArticleResource journalArticleResource = JournalArticleResourceLocalServiceUtil.getJournalArticleResource(ae.getClassPK());
    JournalArticle journalArticle = JournalArticleLocalServiceUtil.getLatestArticle(journalArticleResource.getResourcePrimKey());


    JournalContentUtil.clearCache();
    String content = JournalContentUtil.getContent(journalArticleResource.getGroupId(), journalArticle.getArticleId(), "view", languageId, themeDisplay);

    out.println("<br>"+journalArticle.getTitle(languageId)+"<br>");
    out.println(content);

}
%>

这篇关于按类别获取期刊文章:用Python编写的Liferay Portlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆