How to manage Tags field in user profile?
Hello all,
For a project i'm working on, I have added the classification "Tags" to the Sitefinity userprofile. So now i'm able to add and remove tags per user in the back-end of Sitefinity. I would like to do this on the front-end.
The following page gives instructions for "normal" content items, docs.sitefinity.com/add-and-remove-taxonomies-remove-a-taxon-from-the-associated-content-item. But not for users.
Does anyone know how to be able to add and remove Tags from users?
Thanks!
Regards,
Menderes Demir
Hi Menderes,
Please refer to the below KB article for more details about customizing the User Profile widget template and allow users to edit their profiles and update the desired custom fields from the frontend:
http://www.sitefinity.com/developer-network/knowledge-base/details/how-to-customize-the-userprofile-widget-edit-mode-templates-using-out-of-the-box-fieldcontrols
In the above KB you will find a link to the blog post where this is described in details: http://www.sitefinity.com/blogs/boyan-barnevs-blog-/2014/11/26/how-to-customize-the-userprofile-widget-templates
I used the below markup for the HierarchicalTaxonField as it is shown in the blog post without changing any of the properties. This allows me to edit categories:
<
sf:HierarchicalTaxonField
ID
=
"Category"
DataFieldName
=
"Category"
DisplayMode
=
"Write"
runat
=
"server"
TaxonomyMetafieldName
=
"Category"
TaxonomyId
=
"e5cd6d69-1543-427b-ad62-688a99f5e7d4"
WebServiceUrl
=
"~/Sitefinity/Services/Taxonomies/HierarchicalTaxon.svc"
AllowMultipleSelection
=
"true"
Expanded
=
"false"
ExpandText
=
"Click to add categories"
BindOnServer
=
"true"
/>
<
sf:FlatTaxonField
ID
=
"Tags"
DataFieldName
=
"Tags"
LayoutTemplatePath
=
"~/SFRes/Telerik.Sitefinity.Resources.Templates.Fields.FlatTaxonField.ascx"
DisplayMode
=
"Write"
runat
=
"server"
TaxonomyMetafieldName
=
"Tags"
TaxonomyId
=
"cb0f3a19-a211-48a7-88ec-77495c0f5374"
WebServiceUrl
=
"~/Sitefinity/Services/Taxonomies/FlatTaxon.svc"
AllowMultipleSelection
=
"true"
Expanded
=
"false"
ExpandText
=
"Click to add tags"
BindOnServer
=
"true"
/>
Hi Sabrie,
Thank you for your reply! I forgot to mention, the project is based on pure MVC. How can I implement this in the MVC user detail template?
Regards,
Menderes Demir
Hello Menderes,
In the MVC view of the profile widget you can access classification fields using the below sample which will return a TrackedList of Guids - the ids of the taxa. Here is an example for Tags:
@Model.SelectedUserProfiles[0].Fields.Tags as Telerik.OpenAccess.TrackedList<
Guid
>
@
var tags = Model.SelectedUserProfiles[0].Fields.Tags as Telerik.OpenAccess.TrackedList<
Guid
>;
var tagsCount = tags.Count();
Hi Sabrie,
Thank you for your reply. Getting tags from the (current) user was not the issue. Like my first post, I would like to be able to manage tags of a user.
So being able to add and delete tags from a user on the front-end, without the need of being logged in the back-end of Sitefinity.
With kind regards,
Menderes Demir
Hello Menderes,
Please review the below documentation article related to the Profile widget configurations and check step 3 from the Advanced configuration section where you can find more details on how to make the custom fields editable:
http://docs.sitefinity.com/feather-profile-widget
Regards,
Sabrie Nedzhip
Telerik
Hi Sabrie,
Thank you for your reply. I have followed the instructions on the given page. It looks like it's based on regular fields.
I need to add an editable Tags field. Could you explain me how to add that kind of field?
Thank you.
With kind regards,
Menderes Demir
Don't suppose anyone can shed light on how to perform this?
I want to avoid writing a custom profile edit widget.