Adding Tags to dynamically created content

Posted by Community Admin on 04-Aug-2018 19:02

Adding Tags to dynamically created content

All Replies

Posted by Community Admin on 11-May-2011 00:00

We have custom event, blog post and news item forms that automatically tag the content with tags based on who the users is.

I'm reviewing the Sitefinity 4.x api and I've found the EventManager and Event classes and how to create events using the API, I however cannot find anything about Tags in the API. How to I add tags via codebehind?

-Jon

Posted by Community Admin on 12-May-2011 00:00

Hi Jon Ingersoll,

Thank you for contacting us!

Sitefinity 4.x introduce the powerful technique of using taxonomies. You could read more about what are taxonomies and how they are applied in Sitefinity here:
http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies.html

In case you want to use flat taxonomies(e.g. tags), you could look at samples here:

  1. http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-flat-taxonomies-flat-taxonomy-api.html
  2. http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-associating-items-with-taxa.html

If you continue facing issues please contact us and we will glad to help you.

Best wishes,
Tihomir
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 12-May-2011 00:00

Tihomir,

Thanks for the response, however the example you directed me too appears to have an error. http://www.sitefinity.com/40/help/developers-guide/sitefinity-essentials-taxonomies-associating-items-with-taxa.html).

var taxManager = TaxonomyManager.GetManager();
var taxon = taxManager.GetTaxa<FlatTaxon>().Where(t => t.Name == "Book").Single();
var contentManager = ContentManager.GetManager();
var allContent = contentManager.GetContent();
foreach (var content in allContent)
    content.Organizer.AddTaxa("Tags", taxon);

The AddTaxa method expects a Guid, not a Taxa or Taxon object. The example should say..
content.Organizer.AddTaxa("Tags", taxon.Id);

That is how I've implimented my code and it works, without the .Id the code will not buid.

This thread is closed