Im currently working an a solution where I created an api that can store values in the umbraco solution (as documents) and retreive values such as memberinfo, quizanswers an such.
Im expeiencing some minor problems when publishing the documents I create.
1) Sometimes a node appears twice in the document tree (same text, same id, same childnodes). This I can fix by selecting "Move" and assign the parent node as the new parent node (ie. move it to where it already is).
2) Some of the nodes appears as published in the content tree but doesnt show up in the XmlCache when I use umbraco.library.GetXmlNodeByXPath("..") and iterate through the nodes. this however I can fix by pressing Republish Entire Site on the Content root.
I have to methods where I create and publish content. this is one of them:
I'm doing something similar and sometimes when I publish or save, the node appears twice in the tree. The 2 nodes have the exact same id and children. Anybody got any ideas? I know there is a new tree in the next version of Umbraco but I need this working very soon so waiting isn't really an option.
I have just had the same problem with nodes appearing twice in the tree. Moving it (to the same parent node) corrects the issue. Config file all looked fine so I guess something dodgy had gone on in the database
Publishing documents the right way
Hi Everybody.
Im currently working an a solution where I created an api that can store values in the umbraco solution (as documents) and retreive values such as memberinfo, quizanswers an such.
Im expeiencing some minor problems when publishing the documents I create.
1) Sometimes a node appears twice in the document tree (same text, same id, same childnodes). This I can fix by selecting "Move" and assign the parent node as the new parent node (ie. move it to where it already is).
2) Some of the nodes appears as published in the content tree but doesnt show up in the XmlCache when I use umbraco.library.GetXmlNodeByXPath("..") and iterate through the nodes. this however I can fix by pressing Republish Entire Site on the Content root.
I have to methods where I create and publish content. this is one of them:
private void SubmitSale(int quantum) { Member m = Member.GetCurrentMember(); if (m == null) { this.SetOutput(XmlResponse("Not signed in.")); return; } Document allMemberSalesDoc = new Document(this._salesNodeId); Document currentMemberSales = allMemberSalesDoc.Children .Where(x => x.Text == m.Email) .FirstOrDefault(); if (currentMemberSales == null) { currentMemberSales = Document.MakeNew(m.Email, DocumentType.GetByAlias("Repository"), this.Admin, allMemberSalesDoc.Id); currentMemberSales.Publish(this.Admin); umbraco.library.UpdateDocumentCache(currentMemberSales.Id); } Document memberAnswer = Document.MakeNew(DateTime.Now.ToString("dd-MM-yyyy HH:mm"), DocumentType.GetByAlias("Sale"), this.Admin, currentMemberSales.Id); memberAnswer.getProperty("Quantum").Value = quantum; if(memberAnswer.getProperty("Member")!=null) memberAnswer.getProperty("Member").Value = m.Id; memberAnswer.Save(); memberAnswer.Publish(this.Admin); umbraco.library.UpdateDocumentCache(memberAnswer.Id); this.SetOutput(XmlResponse(true, "Salg oprettet")); }
Any Idea what I might be doing wrong?
kind regards
- Sune Fengel
Sune,
Does normal publish work properly eg via the gui?
Regards
Ismail
Yes it does. I just tested it on a specifik node, and it does seem to work.
- Sune
I'm doing something similar and sometimes when I publish or save, the node appears twice in the tree. The 2 nodes have the exact same id and children. Anybody got any ideas? I know there is a new tree in the next version of Umbraco but I need this working very soon so waiting isn't really an option.
I have just had the same problem with nodes appearing twice in the tree. Moving it (to the same parent node) corrects the issue. Config file all looked fine so I guess something dodgy had gone on in the database
Fengelz and Paul, are you using 4.0.3? I use the same code and it works for me, however not very much tested after I upgraded to 4.0.3.
Just one hint, you don't need to Save the memberAnswer direct before you publish it. The publish will also save the node.
Thomas
Thanks for the replys, the post is 3 months old and I never managed to fizx the problem. The project in question was definitely no umbraco 4.0.3.
Thomas, thanks for the hint I guess I just copied the code from the Umbraco books where I think it says save the node. But I wont do so from now on :)
- Sune
is working on a reply...