Copied to clipboard

Flag this post as spam?

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


  • Chris 69 posts 75 karma points
    Feb 26, 2011 @ 17:38
    Chris
    0

    Publish node with tags datatype

    Hi guys,

    Im writing a .NET routine that creates and publishes a content node wich uses the tags datatype. Everything seems to work fine, except that the tags don't get published. However, they are saved and when i click the 'Save & publish' button manually, the tags do show up in the webpage.

    My code looks like this: 

    doc = Document.MakeNew(txtTitle.Text.Trim(), dt, author, folderId);
    doc.Template = templateId;
    doc.getProperty("Title").Value = txtTitle.Text;             
    doc.getProperty("Description").Value = txtDesc.Text;
    umbraco.editorControls.tags.library.addTagsToNode(doc.Id, txtTags.Text.Trim(), "default");
                
    doc.Save();
    doc.Publish(author);
    umbraco.library.UpdateDocumentCache(doc.Id);
    Does anybody have an idea what I'm missing in my code to get the tags published from code?
    Thanks!

  • E.J. Brennan 73 posts 114 karma points
    Feb 26, 2011 @ 17:54
    E.J. Brennan
    0

    What version are you using?

  • Chris 69 posts 75 karma points
    Feb 26, 2011 @ 18:11
    Chris
    0

    I upgraded to 4.6.1 a couple of weeks ago... Could this be version related?

  • E.J. Brennan 73 posts 114 karma points
    Feb 27, 2011 @ 11:36
    E.J. Brennan
    0

    I only asked about the version because I wanted to make sure I looked at the same version of the code you were running. The code *looks* right to me, at least what I see.

    This post from 5 months ago reported pretty much the same problem as you: http://our.umbraco.org/forum/developers/api-questions/12836-Tags-in-imported-blog-posts-are-not-set-correctly

    Is you txtTag list a comma seperated list of tags? Are there spaces after each tag but before the comma by any chance? Do the tags already exist? or are you trying to create them on save (you should be able to do either, but different code is in play).

  • Chris 69 posts 75 karma points
    Feb 27, 2011 @ 13:55
    Chris
    0

    Hi, thanks for your time!

    Yes, the txtTag is a list of comma seperated tags without any spaces. They get saved to the document node, but don't show up on publish. (Some are new tags which are created fine, others already exist in other content nodes.)

    It seems to be exactly the same problem as in the post you found... which is that the umbraco.config doesnt get updated...  

     

  • E.J. Brennan 73 posts 114 karma points
    Feb 27, 2011 @ 14:45
    E.J. Brennan
    0

    Not sure if it will help, but if you have access to the DB, after you do the save, (but before you do the manual repulish), look into the cmsTags table and the cmsTagRelationship table and see if the rows are added properly. If you do not see the proper data in those two tables, it will be a clue anyway. 

  • Chris 69 posts 75 karma points
    Mar 16, 2011 @ 16:32
    Chris
    0

    Hi again,

    Thanks for the clue. But the tags are added properly to both cmsTags and cmsTagRelationship. I will have to dig a bit deeper into the problem when i find the time. I'll keep this post up to date.

    Chris

  • Daniel.S 50 posts 135 karma points
    Aug 13, 2012 @ 07:21
    Daniel.S
    0

    Did anyone ever figure this out? I'm having the same issue.

  • Valerie 67 posts 163 karma points
    Apr 17, 2014 @ 12:27
    Valerie
    0

    I'm having this issue in v6 - was a solution ever found?

  • Sebastian Hoffback 5 posts 74 karma points c-trib
    Apr 06, 2016 @ 07:46
    Sebastian Hoffback
    0

    I had this issue in 7.3 and the solution was to use SetTags instead of SetValue on IContent.

    Like this:

    IContent content = service.CreateContent("testpage", parentId, "news", authorId);
    content.SetTags("categories", categories.ToDelimitedList(), true, "news");
    service.SaveAndPublishWithStatus(content, authorId);
    
Please Sign in or register to post replies

Write your reply to:

Draft