Dynamically create nodes from a document's template
Assume that there is a document type TypeA and a document type TypeB and that TypeA can have sub elements (allowed child nodetypes) of TypeB.
1) If we have a document of TypeA, say DocA, is it possible to create a button ot input element of type button in DocA's template that when it is pressed, a new document of type DocB is created under DocA?
2) Further more, is it possible to open the newly created node DocB for editing?
For (1) I was trying to find a way to use "/umbraco/dialogs/create.aspx?nodeType=TypeB&app=content&nodeId=(DocA.id)" so that it silently creates DocB, without displaying any dialogs. For (2) we could use an iFrame element that has "/umbraco/editContent.aspx?id=(DocB.id)" as source or an equivalent page for editing DocB in canvas, but we need the id of the new node DocB.
I have tried to pull these together but haven't succeded yet. Can someone show me a correct way of doing it or point me to the right direction?
Just to clatify: Do you want to do this from the frontend, ie. the website, so that external vistors can create pages, or is it an editorial feature for the backend /umbraco users?
I would like to use this functionality in the website, so that the viewers will be able to create and edit documents.
I have already implemented the functionality in the example and created an xslt extension that can be used in a macro. I was trynig to find a way to do it, though, without creating an external user control because I think it would be clearer a solution if I only used code in TypeA's template. What is your opinion?
but it displays the dialog that asks for the node type and the node name (although they are provided as arguments) and then it shows the following error. Am I missing any arguments?
Dynamically create nodes from a document's template
Assume that there is a document type TypeA and a document type TypeB and that TypeA can have sub elements (allowed child nodetypes) of TypeB.
1) If we have a document of TypeA, say DocA, is it possible to create a button ot input element of type button in DocA's template that when it is pressed, a new document of type DocB is created under DocA?
2) Further more, is it possible to open the newly created node DocB for editing?
For (1) I was trying to find a way to use "/umbraco/dialogs/create.aspx?nodeType=TypeB&app=content&nodeId=(DocA.id)" so that it silently creates DocB, without displaying any dialogs. For (2) we could use an iFrame element that has "/umbraco/editContent.aspx?id=(DocB.id)" as source or an equivalent page for editing DocB in canvas, but we need the id of the new node DocB.
I have tried to pull these together but haven't succeded yet. Can someone show me a correct way of doing it or point me to the right direction?
Hi Manthos,
You may want to check out http://our.umbraco.org/wiki/reference/api-cheatsheet/creating-a-document
It goes through how to programatically create a node, you could use the code example when assigned to button click in a usercontrol.
Hope this help, the url way would be quite difficult, this would definitely be the better way of going about creating nodes.
Hi Manthos
Just to clatify: Do you want to do this from the frontend, ie. the website, so that external vistors can create pages, or is it an editorial feature for the backend /umbraco users?
Hi and thank you for your replies!
I would like to use this functionality in the website, so that the viewers will be able to create and edit documents.
I have already implemented the functionality in the example and created an xslt extension that can be used in a macro. I was trynig to find a way to do it, though, without creating an external user control because I think it would be clearer a solution if I only used code in TypeA's template. What is your opinion?
I try to use "/umbraco/dialogs/create.aspx?nodeType=TypeB&app=content&nodeId=(DocA.id)" in an iFrame
<iframe src="/umbraco/dialogs/create.aspx?nodeID=1443&nodeType=Comment&nodeName=ABC&app=content" width="100%">
<a href="/umbraco/dialogs/create.aspx?nodeID=1443&nodeType=Comment&nodeName=ABC&app=content">Add Me<br/>
</iframe>
but it displays the dialog that asks for the node type and the node name (although they are provided as arguments) and then it shows the following error. Am I missing any arguments?
[NullReferenceException]
umbraco.presentation.create.dialogHandler_temp.Create(String NodeType, Int32 TypeId, Int32 NodeId, String Text) +84
umbraco.cms.presentation.create.controls.content.doCreation() +147
umbraco.cms.presentation.create.controls.content.sbmt_Click(Object sender, EventArgs e) +5
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
is working on a reply...