Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
liron bar
get the category from journal article
4 octobre 2011 07:41
Réponse

liron bar

Rang: Junior Member

Publications: 29

Date d'inscription: 27 septembre 2011

Publications Récentes

hello,

i want to display journal article by a given category.
so i'm trying to get from the journal article object his categiries

my question is how do i do it.

i saw in the forum this example:
List<AssetCategory> categories = AssetCategoryServiceUtil.getCategories(JournalArticle.class.getName(), new Long(article1.getArticleId()).longValue());

but it doesnt work.

can anyone help me?

thanks!
liron
Ravi Kumar Gupta
RE: get the category from journal article
4 octobre 2011 07:57
Réponse

Ravi Kumar Gupta

Rang: Liferay Legend

Publications: 1303

Date d'inscription: 23 juin 2009

Publications Récentes

Try with AssetCategoryLocalServiceUtil and article.getId() in place of getArticleId
liron bar
RE: get the category from journal article
4 octobre 2011 08:09
Réponse

liron bar

Rang: Junior Member

Publications: 29

Date d'inscription: 27 septembre 2011

Publications Récentes

thaks for the quick response!

but it's still not working...
liron bar
RE: get the category from journal article
4 octobre 2011 09:24
Réponse

liron bar

Rang: Junior Member

Publications: 29

Date d'inscription: 27 septembre 2011

Publications Récentes

i found the problem,

this is the right way:
List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(JournalArticle.class.getName(), article1.getResourcePrimKey());

enjoy emoticon
Ravi Kumar Gupta
RE: get the category from journal article
4 octobre 2011 10:20
Réponse

Ravi Kumar Gupta

Rang: Liferay Legend

Publications: 1303

Date d'inscription: 23 juin 2009

Publications Récentes

hmm.. thanks for this... i was trying with id, primaryKey, articleId but could not see the resourcePrimKey... will remember this now.. emoticon
shima shima
RE: get the category from journal article
25 août 2014 23:38
Réponse

shima shima

Rang: Junior Member

Publications: 46

Date d'inscription: 13 avril 2014

Publications Récentes

hi Liron
would u plz explain it more. I use liferay 6.2 and free marker .I have used it as this
<#assign article = assetRenderer.getArticle() >
<#assign AssetCategoryLocalService = serviceLocator.findService("com.liferay.portlet.asset.service.AssetCategoryLocalService")>
<#assign categories = AssetCategoryLocalService.getCategories(JournalArticle.class.getName(), article.getResourcePrimKey())/>
but it dose not realize journalArticle
Heiko Ottenbacher
RE: get the category from journal article
5 septembre 2014 06:22
Réponse

Heiko Ottenbacher

Rang: New Member

Publications: 14

Date d'inscription: 5 septembre 2014

Publications Récentes

Hello everybody,

I am trying to get the category from a webcontent article using exactly the way u show here :

1List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories( JournalArticle.class.getName(), oneArt.getResourcePrimKey() );


But I always get an empty list.

I assign the category (actually I can only select one, so it is a bit curious that above method returns a list ;))) by using Content->Web Content -> Categorization and then selecting News from the Select-Box.

So - am I using liferay wrong? Is it the wrong usage of API? Or is it a bug? ;)

Thanks a lot!

Regards, Heiko
Nagendra Kumar Busam
R: get the category from journal article
7 septembre 2014 12:10
Réponse

Nagendra Kumar Busam

Rang: Liferay Master

Publications: 653

Date d'inscription: 7 juillet 2009

Publications Récentes

Heiko,

I think here solution is for asset category selector - they are referring to pop up of categories which is near tags. Not the journal article's type - news/test.

I didn't find one direct method to get articles by type.

You can give it a try with one of search overloaded methods. One more option is dynamic query ( these you can try with JournalArticleLocalServiceUtil). Another have a look at AssetEntryQuery.

Sent from my iPhone with Liferay.com Forums
Nagendra Kumar Busam
R: get the category from journal article
7 septembre 2014 12:09
Réponse

Nagendra Kumar Busam

Rang: Liferay Master

Publications: 653

Date d'inscription: 7 juillet 2009

Publications Récentes

Manali Lalaji
RE: get the category from journal article
7 septembre 2014 02:05
Réponse

Manali Lalaji

Rang: Expert

Publications: 362

Date d'inscription: 9 mars 2010

Publications Récentes

Heiko Ottenbacher:
Hello everybody,

I am trying to get the category from a webcontent article using exactly the way u show here :

1List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories( JournalArticle.class.getName(), oneArt.getResourcePrimKey() );


But I always get an empty list.

I assign the category (actually I can only select one, so it is a bit curious that above method returns a list ;))) by using Content->Web Content -> Categorization and then selecting News from the Select-Box.

So - am I using liferay wrong? Is it the wrong usage of API? Or is it a bug? ;)

Thanks a lot!

Regards, Heiko


Hi,

I think above code shall give you entire information of categories associated with article.

You can try below code, which gives categoryNames:

1
2String[] categoryName = AssetCategoryLocalServiceUtil.getCategoryNames(JournalArticle.class.getName(), 13607); // replace with your classPK
3System.out.println(Arrays.toString(categoryName));
Nagendra Kumar Busam
RE: R: get the category from journal article
7 septembre 2014 12:12
Réponse

Nagendra Kumar Busam

Rang: Liferay Master

Publications: 653

Date d'inscription: 7 juillet 2009

Publications Récentes

It seems Heiko talking about web content type under categorization section - you are speaking about categories/tags related pop up
Heiko Ottenbacher
RE: R: get the category from journal article
8 septembre 2014 02:28
Réponse

Heiko Ottenbacher

Rang: New Member

Publications: 14

Date d'inscription: 5 septembre 2014

Publications Récentes

Thanks Nagendra, thanks Manali for ur help. Nagendra, you are totally right - and with the help of ur example it works now using a Dynamic Query instead of trying to filter it on the fly!

Regards, Heiko