掲示板

Display articles from web content folder (asset pulisher)

thumbnail
8年前 に Dmitry Sergeev によって更新されました。

Display articles from web content folder (asset pulisher)

Junior Member 投稿: 34 参加年月日: 11/11/08 最新の投稿
Hi liferay gurus,

is there a way to display articles from a certain web content folder? I couldn't find it, but I still hope it's possible, just not obvious.
I use LR 6.2 CE GA4.

Thanks!
thumbnail
8年前 に Aravinth Kumar によって更新されました。

RE: Display articles from web content folder (asset pulisher)

Regular Member 投稿: 152 参加年月日: 13/06/26 最新の投稿
Hi,
If you are looking for API
JournalArticleLocalServiceUtil.getArticles(groupId, folderId);
thumbnail
8年前 に Dmitry Sergeev によって更新されました。

RE: Display articles from web content folder (asset pulisher)

Junior Member 投稿: 34 参加年月日: 11/11/08 最新の投稿
Thanks, but unfortunately I'm looking for a way to do it with AssetPublisher configuration, not API.
But I'm starting to get a feeling that I will have to do it programmatically emoticon
thumbnail
8年前 に Aravinth Kumar によって更新されました。

RE: Display articles from web content folder (asset pulisher)

Regular Member 投稿: 152 参加年月日: 13/06/26 最新の投稿
Hi,
Dont know.whether this will help you.Just give a try with this configuration
Then In asset publisher configuration

Under asset selection tab choose manual
Then under that asset entries select web content folder choose the folder you want.
thumbnail
8年前 に Dmitry Sergeev によって更新されました。

RE: Display articles from web content folder (asset pulisher)

Junior Member 投稿: 34 参加年月日: 11/11/08 最新の投稿
Yes, I've tried that. AP displays folder itself, not articles from the folder.
thumbnail
8年前 に Emma Liu によって更新されました。

RE: Display articles from web content folder (asset pulisher)

New Member 投稿: 9 参加年月日: 12/03/29 最新の投稿
Hi Dmitry,

As far as I know, this might not be possible for now without customization. You may try voting this ticket: LPS-53044.

Regards,
Emma
thumbnail
8年前 に Dmitry Sergeev によって更新されました。

RE: Display articles from web content folder (asset pulisher)

Junior Member 投稿: 34 参加年月日: 11/11/08 最新の投稿
Thanks, Emma!
thumbnail
7年前 に Freddy Yang によって更新されました。

RE: Display articles from web content folder (asset pulisher)

New Member 投稿: 1 参加年月日: 16/09/09 最新の投稿
I still need this function for my app, and I searched, here is the solution, hope it will be helpful for some guys:
(You should replace the folderID with what you want.)

<#assign folderId = staticUtil["java.lang.Long"]>
<#assign folderId=folderId.valueOf("23826")>
<#assign groupId = themeDisplay.getSiteGroupId()>

<#assign journalArticleLocalServiceUtil = staticUtil["com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil"]>
<#assign journalArticleClazz = staticUtil["com.liferay.portal.kernel.util.ClassResolverUtil"].resolveByPortalClassLoader("com.liferay.portlet.journal.model.JournalArticle")>
<#assign dynamicQueryFactoryUtil = objectUtil("com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil")>
<#assign portalClassLoader = objectUtil("com.liferay.portal.kernel.util.PortalClassLoaderUtil")>
<#assign propertyFactoryUtil = objectUtil("com.liferay.portal.kernel.dao.orm.PropertyFactoryUtil")>
<#assign orderFactoryUtil = objectUtil("com.liferay.portal.kernel.dao.orm.OrderFactoryUtil")>
<#assign projectionFactoryUtil = objectUtil("com.liferay.portal.kernel.dao.orm.ProjectionFactoryUtil")>

<#assign maxVersionArticle_dq = dynamicQueryFactoryUtil.forClass(journalArticleClazz,"maxVersionArticle")>
<#assign VOID1 = maxVersionArticle_dq.add(propertyFactoryUtil.forName("articleId").eqProperty("articleByType.articleId"))>
<#assign VOID1 = maxVersionArticle_dq.setProjection(projectionFactoryUtil.max("id"))>

<#assign articleByType_dq = dynamicQueryFactoryUtil.forClass(journalArticleClazz,"articleByType")>
<#assign VOID2 = articleByType_dq.add(propertyFactoryUtil.forName("id").eq(maxVersionArticle_dq))>
<#assign VOID2 = articleByType_dq.add(propertyFactoryUtil.forName("folderId").eq(folderId))>
<#assign VOID2 = articleByType_dq.add(propertyFactoryUtil.forName("groupId").eq(groupId))>
<#assign VOID2 = articleByType_dq.addOrder(orderFactoryUtil.desc("modifiedDate"))>

<#assign articles = journalArticleLocalServiceUtil.dynamicQuery(articleByType_dq)>

<#if articles?has_content>
	<#list articles as journalArticle>
		<div>${journalArticle.titleCurrentValue}</div>
	<!--#list-->
<!--#if-->	


The matched Java Code:


		List<journalarticle> articleList = null;

		try {

			//OrderByComparator obc = new ArticleModifiedDateComparator(false);
			//articleList = JournalArticleLocalServiceUtil.getArticles(groupId, folderId, start, end, obc);
			
			DynamicQuery maxVersionArticle = DynamicQueryFactoryUtil
					.forClass(JournalArticle.class, "maxVersionArticle", PortalClassLoaderUtil.getClassLoader())
					.add(PropertyFactoryUtil.forName("articleId").eqProperty("articleByType.articleId"))
					.setProjection(ProjectionFactoryUtil.max("id"));

			// articleByType : Query will find the articles by its type and
			// appended the maxVersionArticle query so it will track only latest versions
			
			DynamicQuery articleByType = DynamicQueryFactoryUtil
					.forClass(JournalArticle.class, "articleByType", PortalClassLoaderUtil.getClassLoader())
					.add(PropertyFactoryUtil.forName("id").eq(maxVersionArticle))
					.add(PropertyFactoryUtil.forName("folderId").eq(folderId))
					.add(PropertyFactoryUtil.forName("groupId").eq(groupId))
					.addOrder(OrderFactoryUtil.desc("modifiedDate"));

			articleByType.setLimit(start, end);

			articleList = (List<journalarticle>) JournalArticleLocalServiceUtil.dynamicQuery(articleByType);
			
			
		} catch (SystemException e) {
			e.printStackTrace();
		} 
</journalarticle></journalarticle>



Regards