Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: get the category from journal article
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
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
Try with AssetCategoryLocalServiceUtil and article.getId() in place of getArticleId
thaks for the quick response!
but it's still not working...
but it's still not working...
i found the problem,
this is the right way:
List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(JournalArticle.class.getName(), article1.getResourcePrimKey());
enjoy
this is the right way:
List<AssetCategory> categories = AssetCategoryLocalServiceUtil.getCategories(JournalArticle.class.getName(), article1.getResourcePrimKey());
enjoy

hmm.. thanks for this... i was trying with id, primaryKey, articleId but could not see the resourcePrimKey... will remember this now..

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
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
Hello everybody,
I am trying to get the category from a webcontent article using exactly the way u show here :
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
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
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));
Nagendra Kumar Busam, modified 11 Years ago.
Liferay Master
Posts: 678
Join Date: 7/7/09
Recent Posts
It seems Heiko talking about web content type under categorization section - you are speaking about categories/tags related pop up
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
Regards, Heiko
Nagendra Kumar Busam, modified 11 Years ago.
Liferay Master
Posts: 678
Join Date: 7/7/09
Recent Posts
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
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, modified 11 Years ago.
Liferay Master
Posts: 678
Join Date: 7/7/09
Recent Posts
Dynamic query example
http://liferayinsight.blogspot.com/2014/04/find-liferay-journal-atticles-by-type.html
Sent from my iPhone with Liferay.com Forums
http://liferayinsight.blogspot.com/2014/04/find-liferay-journal-atticles-by-type.html
Sent from my iPhone with Liferay.com Forums
Hi everyone! I'm looking for how delete one type of categories from all articles? If somebody know, please tell me.
Thanks!
Thanks!
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.
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.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™