Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Yann Perrin 6 posts 26 karma points
    May 07, 2014 @ 03:44
    Yann Perrin
    0

    Umbraco 7 Managing Tags

    Hi all,

    Sorry I am a bit of a newbie. I have been going over the source code a little and I could not find an easy way for me to do this.

    I am trying to list the tags for a given group, that I can do. But then I am trying to load all documents associated with a tag, potentially remove a tag not in use.

    Being able to rename a tag would also be nice. Basically funcitonality from TagManager but a little more specific to our configuration and some of it I would want to show in the UI as well.

    Now I looked for an API where I could get documents/nodes for a given tag or delete a tag. There does not seem to be anything quite like that. I could follow the road taken by TagManager and directly access the tables but before I went there I wanted to make sure there is not anything else available for me to use.

    Any help would be appreciated, thanks

  • Yann Perrin 6 posts 26 karma points
    May 12, 2014 @ 20:27
    Yann Perrin
    0

    ok I have given up and using the DatabaseContext to get some information about the tags.

    Here is what I am using for now in case someone comes up with a better way

     

            public static IList<Tags> GetTags(DatabaseContext databaseContext, string[] group = null)
           {
               var sql = new StringBuilder("Select id, tag as name, [group], count(cmsTagRelationship.nodeid) as documentcount From cmsTags, cmsTagRelationship where cmsTags.id = cmsTagRelationship.tagId");
               sql.Append(" group by id, tag, [group]");
               sql.Append(" order by [group], tag");
               var db = databaseContext.Database;
               var tagList = db.Fetch<Tag>(sql.ToString());

    Thanks

  • Søren Reinke 158 posts 206 karma points c-trib
    Jun 25, 2014 @ 11:34
    Søren Reinke
    1

    Take a look at the new TagService:
    https://github.com/umbraco/Umbraco-CMS/blob/7.1.5/src/Umbraco.Core/Services/TagService.cs

    Maybe it can help you? 

  • Yann Perrin 6 posts 26 karma points
    Jun 25, 2014 @ 13:38
    Yann Perrin
    0

    I had to come up with something, so I am using database and Petapoco. 

    This way I can create the equivalent of a tag cloud and getting number of documents per tag. Also created a related documents using tags, the more tgas they have in common the more related they are. Not that great but good enough.

     

    Thanks for the help, I will see if I can use it to improve what I have already implemented.

  • Jonas Eriksson 930 posts 1825 karma points
    Jul 04, 2014 @ 16:05
    Jonas Eriksson
    1

    TagQuery is the recommended way afaiu, i.e Umbraco.TagQuery.GetContentByTagGroup("default"); <- returns all IPublishedContent with tags in that group. However it does also return some with empty tags it seems. So Umbraco.TagQuery.GetContentByTagGroup("default").Where(d=>d.HasValue("myTagProperty")) is better.

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies