Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hugo Palma
How to get category from JournalArticle
September 11, 2009 10:55 AM
Answer

Hugo Palma

Rank: New Member

Posts: 20

Join Date: September 13, 2007

Recent Posts

Hi everyone,
i have a JournalArticle and i would like to know which category it belongs to, but i can't find anything in the JournalArticle or any other class that would let me find it.

Any ideas ?
Thanks.
Zsolt Balogh
RE: How to get category from JournalArticle
September 11, 2009 12:06 PM
Answer

Zsolt Balogh

LIFERAY STAFF

Rank: Expert

Posts: 463

Join Date: March 23, 2009

Recent Posts

You should try this:
1AssetCategoryServiceUtil.getCategories(JournalArticle.class.getName(), articleId);
Hugo Palma
RE: How to get category from JournalArticle
September 15, 2009 1:30 AM
Answer

Hugo Palma

Rank: New Member

Posts: 20

Join Date: September 13, 2007

Recent Posts

Zsolt Balogh:
You should try this:
1AssetCategoryServiceUtil.getCategories(JournalArticle.class.getName(), articleId);


Thanks, your reply lead me to TagsAssetServiceUtil which does the job. It seems AssetCategoryServiceUtil doesn't exist anymore.
Zsolt Balogh
RE: How to get category from JournalArticle
September 15, 2009 2:02 AM
Answer

Zsolt Balogh

LIFERAY STAFF

Rank: Expert

Posts: 463

Join Date: March 23, 2009

Recent Posts

I was checking that in the latest trunk, so I think it will be the future emoticon
liferay developer
RE: How to get category from JournalArticle
March 30, 2010 6:32 AM
Answer

liferay developer

Rank: New Member

Posts: 12

Join Date: March 30, 2010

Recent Posts

Hi there,

can you explain how to get category from JournalAricle IN THE PRESENT?

I am extending journal articles portlet and I need to filter by category.

Thanks
Roberto Tellado
RE: How to get category from JournalArticle
March 30, 2010 11:40 PM
Answer

Roberto Tellado

Rank: Regular Member

Posts: 246

Join Date: September 15, 2009

Recent Posts

Hello,

In the version 6, you can filter by category in the asset publisher. You can view the code, and implement it in your code.

Sorry for my english.

Regards.
Edouard Perr
RE: How to get category from JournalArticle
September 20, 2012 9:23 AM
Answer

Edouard Perr

Rank: Junior Member

Posts: 30

Join Date: August 20, 2012

Recent Posts

Hello,

Because it is the first result in Google concerning this question, I add the way to retrieve journal article categories (and tags).

Zsolt Balogh said :
1AssetCategoryServiceUtil.getCategories(JournalArticle.class.getName(), articleId);


I tried with : ja.getId() / ja.getArticleId() / ja.getPrimaryKey() None of these worked.

Actually you need this :
1List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(JournalArticle.class.getName(), ja.getResourcePrimKey());
2List<AssetTag> tags = AssetTagLocalServiceUtil.getTags(JournalArticle.class.getName(), ja.getResourcePrimKey());


It can be useful for new comers.
I found it in the post here, which is not well-referenced by google compared to this one.

Regards.
Edouard