Forums de discussion

get the category from journal article

liron bar, modifié il y a 12 années.

get the category from journal article

Junior Member Publications: 29 Date d'inscription: 28/09/11 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
thumbnail
Ravi Kumar Gupta, modifié il y a 12 années.

RE: get the category from journal article

Liferay Legend Publications: 1302 Date d'inscription: 24/06/09 Publications récentes
Try with AssetCategoryLocalServiceUtil and article.getId() in place of getArticleId
liron bar, modifié il y a 12 années.

RE: get the category from journal article

Junior Member Publications: 29 Date d'inscription: 28/09/11 Publications récentes
thaks for the quick response!

but it's still not working...
liron bar, modifié il y a 12 années.

RE: get the category from journal article

Junior Member Publications: 29 Date d'inscription: 28/09/11 Publications récentes
i found the problem,

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

enjoy emoticon
thumbnail
Ravi Kumar Gupta, modifié il y a 12 années.

RE: get the category from journal article

Liferay Legend Publications: 1302 Date d'inscription: 24/06/09 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, modifié il y a 9 années.

RE: get the category from journal article

Junior Member Publications: 46 Date d'inscription: 14/04/14 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, modifié il y a 9 années.

RE: get the category from journal article

New Member Publications: 20 Date d'inscription: 05/09/14 Publications récentes
Hello everybody,

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

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


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
thumbnail
Manali Lalaji, modifié il y a 9 années.

RE: get the category from journal article

Expert Publications: 362 Date d'inscription: 09/03/10 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 :

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


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:


String[] categoryName = AssetCategoryLocalServiceUtil.getCategoryNames(JournalArticle.class.getName(), 13607); // replace with your classPK
System.out.println(Arrays.toString(categoryName));
thumbnail
Nagendra Kumar Busam, modifié il y a 9 années.

RE: R: get the category from journal article

Liferay Master Publications: 678 Date d'inscription: 07/07/09 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, modifié il y a 9 années.

RE: R: get the category from journal article

New Member Publications: 20 Date d'inscription: 05/09/14 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
thumbnail
Nagendra Kumar Busam, modifié il y a 9 années.

R: get the category from journal article

Liferay Master Publications: 678 Date d'inscription: 07/07/09 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
thumbnail
Nagendra Kumar Busam, modifié il y a 9 années.

R: get the category from journal article

Liferay Master Publications: 678 Date d'inscription: 07/07/09 Publications récentes
Alberto Imaginanet, modifié il y a 3 années.

RE: get the category from journal article

New Member Publications: 12 Date d'inscription: 14/02/20 Publications récentes
Hi everyone! I'm looking for how delete one type of categories from all articles? If somebody know, please tell me.
Thanks!
thumbnail
Christoph Rabel, modifié il y a 3 années.

RE: get the category from journal article

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
You shouldn't capture other peoples old threads. your question is different then the thread topic.
You could use AssetEntryLocalService.clearAssetCategoryAssetEntries(long categoryId) to delete all of them or fetch a list of entries getAssetCategoryAssetEntries, iterate through it and remove only some of them. Depends on your usecase.