16 February, 2011

Article by tag name

As Now we are moving with liferay 6 we would have lot many requirements
to find the articles by tag name.So in liferay-6 i found little bit
change to find the articles according to tags in comparison with liferay 5.2.X.
So here below i have put the code snippet to find articles by tag for liferay 6.
Hope it will be usefull !!!



public List findArticleByTag(ThemeDisplay themeDisplay , String tagName) throws PortalException, SystemException{
  AssetTag assetTagObj = AssetTagLocalServiceUtil.getTag(themeDisplay.getScopeGroupId(), tagName);  
  long tagid = assetTagObj.getTagId(); 
  AssetEntryQuery assetEntryQuery = new AssetEntryQuery(); 
  long[] anyTagIds = {tagid};  
  assetEntryQuery.setAnyTagIds(anyTagIds);  
  List assetEntryList = AssetEntryLocalServiceUtil.getEntries(assetEntryQuery);  
  List journalArticleList =new ArrayList();  
  for(AssetEntry ae : assetEntryList)
  {  
     JournalArticleResource journalArticleResourceObj = JournalArticleResourceLocalServiceUtil.getJournalArticleResource(ae.getClassPK()); 
     JournalArticle journalArticleObj = JournalArticleLocalServiceUtil.getArticle(themeDisplay.getScopeGroupId(),journalArticleResourceObj.getArticleId());  
     journalArticleList.add(journalArticleObj); 
  } 
  return journalArticleList;  
 }

Rate Me:

Liferay 7.3 compatibility matrix

Compatibility Matrix Liferay's general policy is to test Liferay Portal CE against newer major releases of operating systems, open s...