Message Boards

Liferay filtr by categories

Alberto Imaginanet, modified 3 Years ago.

Liferay filtr by categories

New Member Posts: 12 Join Date: 2/14/20 Recent Posts
Hello everyone!!!
I am creating two portlets. One of them shows articles with categories. Second portlet shows articles without categories. 
The problem is with the second portlet. If one of the articles was in the first portlet and then delete the category, the second portlet does not show these articles.I deleted category from article just delete information in the table AssetEntryAssetCategoryRel. 
Maybe I need change something else fo that?
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Liferay filtr by categories

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Alberto Imaginanet:

I am creating two portlets. One of them shows articles with categories. Second portlet shows articles without categories. 
The problem is with the second portlet. If one of the articles was in the first portlet and then delete the category, the second portlet does not show these articles.I delete category from article just delete information in the table AssetEntryAssetCategoryRel. 
Maybe I need change something else fo that?
I don't fully understand your question, but if you "delete information in [a] table", then yes, you need to change something. Most likely you've broken your installation and should restart with this vital information (see link) in mind.

Also: You're not supposed to change any underlying data in the render phase. The order of evaluation of rendering the portlets is undefined, and nothing in the container's implementation expects changes to underlying business state from your portlet being rendered.
Alberto Imaginanet, modified 3 Years ago.

RE: Liferay filtr by categories

New Member Posts: 12 Join Date: 2/14/20 Recent Posts
Hi Olaf!
Thanks for your reply.I need to remove a category from an article. How can I do this from my service? not from web content. What table contains information about which categories an article belongs to?
thumbnail
Olaf Kock, modified 3 Years ago.

RE: Liferay filtr by categories

Liferay Legend Posts: 6403 Join Date: 9/23/08 Recent Posts
Alberto Imaginanet:

Hi Olaf!
Thanks for your reply.I need to remove a category from an article. How can I do this from my service? not from web content. What table contains information about which categories an article belongs to?

"What table contains...?": Wrong question! See the article that I linked in my previous answer! Print the ER-diagram poster, hang it in your workspace and make sure to fill out the missing parts.
You'll have to look through the API containing "Asset" and "Category". AssetEntryAssetCategoryRelLocalService looks like a candidate in case you don't need permission checks. There might be other candidates - there's quite a lot of Asset*Services around that I'm not sure to hit the right one on first try. Also, you might want to use the (non-Local) Service to utilize permission checks during the operation.
Alberto Imaginanet, modified 3 Years ago.

RE: Liferay filtr by categories

New Member Posts: 12 Join Date: 2/14/20 Recent Posts
Yes, I'm using 
AssetEntryAssetCategoryRelLocalServiceUtil.[i]deleteAssetEntryAssetCategoryRelByAssetCategoryId[/i](categoryID);
for delete category from article. 
but when I choose all articles without this category (in configuration of asset publisher - not include these category) .
I do not get any of these articles. All of them filtre with this category. But they don't really have this category if you look inside the article

But if I'm updating article - this article appears in a list without categories
So I need to update and save each one articles without category. But I don't know how to do it from listener.