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);
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.
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.
Hi Ally,
Have you tried:
http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing
Worth a shot!
Kenny
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
Hmmm...
Anything showing up in the log table?
K
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
is working on a reply...