More in this section

Forums / Developing with Sitefinity / Adding Tags to dynamically created content

Adding Tags to dynamically created content

3 posts, 1 answered
  1. Jon Ingersoll
    Jon Ingersoll avatar
    32 posts
    Registered:
    12 May 2009
    11 May 2011
    Link to this post
    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
  2. Tihomir
    Tihomir avatar
    23 posts
    Registered:
    09 Dec 2016
    12 May 2011
    Link to this post
    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
    Answered
  3. Jon Ingersoll
    Jon Ingersoll avatar
    32 posts
    Registered:
    12 May 2009
    12 May 2011
    Link to this post
    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.
3 posts, 1 answered