Fórum

How to find List a journal Articles in particular page ?

RAVI RAJAMANI, modificado 7 Anos atrás.

How to find List a journal Articles in particular page ?

Regular Member Postagens: 123 Data de Entrada: 07/12/14 Postagens Recentes
How to find a list of jouranal Artices in a particular Page ?

Is there any JournalArticel API to find the list Articles depending on page(Layout) basic.


I have gone through this class

In this class
Class JournalArticleLocalServiceUtil

this are following methods which returning list of articles. in this i cannot able to find .

 static List<journalarticle> 	getArticles()
          Returns all the web content articles present in the system.
static List<journalarticle> 	getArticles(long groupId)
          Returns all the web content articles belonging to the group.
static List<journalarticle> 	getArticles(long groupId, int start, int end)
          Returns a range of all the web content articles belonging to the group.
static List<journalarticle> 	getArticles(long groupId, int start, int end, OrderByComparator obc)
          Returns an ordered range of all the web content articles belonging to the group.
static List<journalarticle> 	getArticles(long groupId, long folderId)
          Returns all the web content articles matching the group and folder.
static List<journalarticle> 	getArticles(long groupId, long folderId, int start, int end)
          Returns a range of all the web content articles matching the group and folder.
static List<journalarticle> 	getArticles(long groupId, long folderId, int status, int start, int end)
           
static List<journalarticle> 	getArticles(long groupId, long folderId, int start, int end, OrderByComparator orderByComparator)
          Returns an ordered range of all the web content articles matching the group and folder.
static List<journalarticle> 	getArticles(long groupId, String articleId)
          Returns all the web content articles matching the group and article ID.
static List<journalarticle> 	getArticlesByResourcePrimKey(long resourcePrimKey)
           
static List<journalarticle> 	getArticlesBySmallImageId(long smallImageId)
          Returns all the web content articles matching the small image ID.

</journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle></journalarticle>


Is there any way find a List of Journal Articles on the Page Basic ?

Regards,
Ravi R
Oliver Bayer, modificado 7 Anos atrás.

RE: How to find List a journal Articles in particular page ?

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Ravi,

the last time I worked with Liferay version 6.1 was the most recent one so I don't know if anything has changed regarding APIs. But I had the following requirement and found the following workaround:
  • check layout table to get all portlets with 56_* in the typesettings column based on a given plid
  • based on the portlet ids found on step 1 check portletpreferences table by using plid and portletid to get the preferences with the article id
  • use the JournalLocalServiceUtil to read the article by using the article id and group id

HTH Oli
RAVI RAJAMANI, modificado 7 Anos atrás.

RE: How to find List a journal Articles in particular page ?

Regular Member Postagens: 123 Data de Entrada: 07/12/14 Postagens Recentes
Oliver Bayer:

check layout table to get all portlets with 56_* in the typesettings column based on a given plid


Getting portlets from the Layout table.
1) themeDisplay.getLayoutTypePortlet().getAllPortlets();--- this will give the List of portlets
2) themeDisplay.getLayoutTypePortlet().getAllPortlets(columnId);--This will return list of portlets on String ColumnId basic.

the Above API is there to fetch the list of portlet on Column based.

How to pass the Layout column type "typesettings column"in above API

or
How to take column from the Layout Table.

Regards,
Ravi R
Oliver Bayer, modificado 7 Anos atrás.

RE: How to find List a journal Articles in particular page ?

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hi Ravi,

I didn't know this API method but this will make things easier. So you don't have to filter the typesettings column.
Following up some pseudo-like code.
List<string> webcontentPortletIds = new ArrayList<string>();
List<portlet> allPortletsOnPage = themeDisplay.getLayoutTypePortlet().getAllPortlets();
Iterator<portlet> portletItr = allPortletsOnPage.itarator();
while (portletItr.hasNext())
{
   Portlet p = portletItr.next();
   //   remove all portlets from list which aren't webcontents
   if (p.getId != 56)
   {
      portletItr.remove();
   }
   else
   {
      webcontentPortletIds.add(p.getPortletId());
   }
}
for (String portletId : webcontentPortletIds)
{
   PortletPreferencesLocalServiceUtil.getPortletPreferences(<your-plid>, portletId);
   // use portlet.getPreferences() and extract the article-id
}</your-plid></portlet></portlet></string></string>

Oli
RAVI RAJAMANI, modificado 7 Anos atrás.

RE: How to find List a journal Articles in particular page ?

Regular Member Postagens: 123 Data de Entrada: 07/12/14 Postagens Recentes
Thanks Oliver Bayer,

Clarification

Following up some pseudo-like code.
 
Portlet p = portletItr.next();
   //   remove all portlets from list which aren't webcontents
  if (p.getId != 56)
  { 
      portletItr.remove();
   }


The code p.getId() was returning 0 to all the portlets.
is there was any other option.

and

PortletPreferencesLocalServiceUtil.getPortletPreferences(<your-plid>, portletId);
use portlet.getPreferences() and extract the article-id</your-plid>


in this above code <youp-plid> is from like this
long sd= themeDisplay.getPlid();

// use portlet.getPreferences() and extract the article-id


What is the portlet in this ?
Oliver Bayer, modificado 7 Anos atrás.

RE: How to find List a journal Articles in particular page ?

Liferay Master Postagens: 894 Data de Entrada: 18/02/09 Postagens Recentes
Hmm returning 0 for all portlets on the page seems strange. Maybe you can use
if (p.getPortletId().startsWith("56_"))

The easiest way to find the correct method would be to place a breakpoint and inspect which attributes p has. I'm not sure if getPortletId() is returning the portlet + INSTANCE_ID but if so the above snippet should work.

Sorry my fault emoticon. The getPortletPreferences() method returns a list of portlet preferences. Normally -at least for webcontents- you should only have one per portlet.
List<portletpreferences> portletPrefList = PortletPreferencesLocalServiceUtil.getPortletPreferences(themeDisplay.getPlid(), portletId);
String portletPrefs = portletPrefList.get(0).getPreferences();

//   now extract the article-id from portletPrefs as articleId
//   then use JournalArticleLocalServiceUtil.getArticle(themeDisplay.getGroupId(), articleId);</portletpreferences>

Remember this is pseudo code and not production ready e.g the line portletPrefList.get(0) will throw a NullPointerException if the list isn't set.