3
votes

I have a .NET(C#) script which is pulling news articles from an XML file. Everything works fine, but when it comes to publishing them, and appearing on the web page, something's not quite right.

Here's the code so far:

            try {
                    newNode.Save();
                    newNode.Publish(User.GetUser(0));   //0 is default user
                }
                catch (Exception ex) {
                    // error message
                }
                umbraco.library.UpdateDocumentCache(newNode.Id);

As you can see, what I'm trying to publish is newNode. It's first saved and then published through User 0, which has publishing rights, and then the document cache is updated. The problem is that it appears in the back end of Umbraco, but the document link is simply a single hash (#), and it doesn't display on the web page.

Can anyone suggest why this method of publishing wouldn't work?

Edit: Should have mentioned, I'm using Umbraco 4.7.1

1

1 Answers

5
votes

If newNode is a child of a node that you are also creating, you'll need to publish and update the document cache for the parent node before publishing (and updating the cache) of its children. At any rate, the parent node needs to be published beforehand. Try republishing the entire site before and, if it still doesn't work, after.

Republishing the entire site:

  1. Right click the Content node.
  2. Select "Republish entire site" from the menu.
  3. Click the "Republish entire site" button.

It should be really quick, as all this is doing is rebuilding the umbraco.config cache file.