Copied to clipboard

Flag this post as spam?

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


  • Ally Watson 16 posts 37 karma points
    Oct 05, 2012 @ 15:42
    Ally Watson
    0

    Publishing node but not updating umbraco.config

    I’m having an issue and I’ve been on a dozen forum posts and still can’t get this to work. I am trying to programmatically add a new node.

    Scenario: I have created a form that allows you to create a node using the front end of the site. You enter a name for the node and press submit. This then goes off and programmatically creates the new node and publishes it. The page refreshes and shows a list of all my published nodes... however my newly created node is not there.

    I check the backend and the page is in black text and displayed as published... so I then check the umbraco.config but the xml hasn't updated and does not contain my new node's details. 

    It is only when I manually press 'save & publish' that the xml updates. Oh and NOW it's appears in the front end. 

     

     

    Document newFolder = Document.MakeNew(folderName,DocumentType.GetByAlias("NodeTypeAliasHere"), new User(0),clientAreaRoot);

    newFolder.getProperty("memberAccess").Value = memberId.ToString();

    newFolder.Save();

    newFolder.Publish(new User(0));

    library.UpdateDocumentCache(newFolder.Id);

     

    I'm using umbraco 4.7.1.1

    I have tried a few solutions now and welcome to any suggestions! Thanks in advance. 

  • Kenny Burns 173 posts 305 karma points
    Oct 05, 2012 @ 15:56
    Kenny Burns
    0

    Hi Ally,

    Have you tried:

    umbraco.library.RefreshContent();
    http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing
     Worth a shot! 
    Kenny
  • Ally Watson 16 posts 37 karma points
    Oct 05, 2012 @ 16:23
    Ally Watson
    0

    Hey Kenny,

    Thanks for the suggestion. Unfortunately I've tried most things on that page inlcuding the generateXml option and still nada nothing zilch!! 

    I keep thinking I MUST be missing something/doing something wrong/permissions maybe?...

    Thanks,
    Ally

  • Kenny Burns 173 posts 305 karma points
    Oct 05, 2012 @ 16:39
    Kenny Burns
    0

    Hmmm...

    Anything showing up in the log table?

    K

  • Jon Free 14 posts 34 karma points
    Jan 18, 2013 @ 11:50
    Jon Free
    0

    Ally,

    I've done a fair bit of programttic work on nodes recently and have found publishing to be very hap hazard. It seems like the Publish method always completes within the code and without throwing an error but that doesn't neccesarily mean it published fully. Like you said it usually creates the node and it becomes visible in the back end but won't always show on the site. 

    Is your code literally that simple? As if it's part of several parent/child node creations that all happen at the same time this can effect it. 

    Secondly, try running debug with breakpoints on your creation code and on your rendering code (probaly in a razor or xslt file). You may find you're not creating the node until after the razor file has rendered the page, hence it won't have existsed when the page reloads. Another easy way to check would be to load the page a second time, at which point the new node should display.

    Hope that helps 

Please Sign in or register to post replies

Write your reply to:

Draft