Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Update categories?
olaj
#1 Posted : Friday, February 12, 2010 5:02:20 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 12/31/2009(UTC)
Posts: 79
Location: Göteborg, Sweden
What is the best practice to update categories on an item? Do i have to get an array of Guid's before updating and so on? Or can i just add a category?
jifeng
#2 Posted : Sunday, February 14, 2010 9:58:53 AM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
Yes, right now you need to get the old categories to reset.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
olaj
#3 Posted : Sunday, February 14, 2010 6:33:31 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 12/31/2009(UTC)
Posts: 79
Location: Göteborg, Sweden
Ahh, ok. This can create some really nasty bugs :) Understand that you are busy but this probably need an update.
jifeng
#4 Posted : Sunday, February 14, 2010 9:18:37 PM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
Yes, we will improve it in future. Thanks.
Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
NazGewt
#5 Posted : Monday, July 05, 2010 6:14:42 PM(UTC)
Rank: Newbie
Groups: Registered

Joined: 7/4/2010(UTC)
Posts: 3
Location: Chanmester
I got this working ok, the problem I think olaj is referring is perhaps the "unsuccessful control" functionality in browsers (and html spec) meaning they don't return unchecked check boxes in the request when a form is submitted. This means you have to clear all categories first before updating existing categories otherwise the user won't be able to clear all checkboxes and clear all categories from a content item.

Assuming you have the source content item's guid you just just need to call GetContentsBySchema() for each schema that is a category on your source item's schema. From here you can get the ["UUID"] and call RemoveCategoryFromContent() :

Code:
CmsContext.ContentService.RemoveCategoryFromContent( oSourceContentItem_Guid, (Guid)oCategoryItem["UUID"]);


It doesn't matter if the category item is not currently selected for the source content item, RemoveCategoryFromContent() just ignores it, so I just send all possible categories to RemoveCategoryFromContent()

Once you have cleared all categories you are free to pass an array of selected category guids to the UpdateContent() function. The great thing about the array of guids is that you don't have to specify which category schema they relate to as Kooboo figures it out for you. What this means is that if you have two or more category schemas in a content item schema then you don't have to do anything extra, all category guids go in the same array

Kooboo people
I saw a post where you said you were unhappy with the current category support within the Kooboo API and were recommending that people don't use it so you can make changes. However I'm happy with it and I have code that relies on it working the way it currently does. So if you do change the way category handles can you please add it as new functionality and keep RemoveCategoryFromContent() and the array of category guids in UpdateContent()?

Thanks

ps: This is GazNewt but I can't unlock my old account as I have apparently forgotten the name of my dog!
jifeng
#6 Posted : Monday, July 05, 2010 6:59:15 PM(UTC)
Rank: Administration
Groups: Administrators, Registered

Joined: 9/3/2009(UTC)
Posts: 1,552
Location: Xiamen China
GazNewt,

We have reset your password, I think one email has been sent to you. We also PM you the new password already.

I did not remember what changes we are going to make to category schema, but your implementation seems like will not be affected. We might offer additional APIs.

Regards,

Jifeng Huang

Kooboo Team

Microsoft ASP.NET MVP
GazNewt
#7 Posted : Monday, July 05, 2010 7:02:38 PM(UTC)
Rank: Advanced Member
Groups: Registered

Joined: 2/2/2010(UTC)
Posts: 122
Location: England
Thanks Jifeng, and thanks also I am back in on my original account.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF 1.9.5.5 | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.539 seconds.