Refreshing the detail panel after deleting node in custom tree
Hi,
I'm doing a custom tree/section and I'm implementing a customtasks.cs with tasks to fire when adding new nodes and deleting old ones.
The code for adding a new node works fine with the detail panel showing the content of the new node upon saving.
However, when deleting the detail panel still shows the content of the deleted node after execution. How do I get the detail panel to show other content?
Code shown below, the node's id is stored in the parentID property.
Best,
Johannes
using System; using System.Collections.Generic; using System.Web; using System.Linq; using System.Web.UI; using System.Web.UI.WebControls; using umbraco.cms.businesslogic.web; using umbraco.BusinessLogic; using umbraco.NodeFactory; using umbraco.BasePages; using umbraco.cms.businesslogic.member;
namespace CustomUmbracoSection.Tasks { public class CustomTasks : umbraco.interfaces.ITaskReturnUrl { private string _alias; private int _parentID; private int _typeID; private int _userID;
public int UserId { set { _userID = value; } }
public int TypeID { set { _typeID = value; } get { return _typeID; } }
public int ParentID { set { _parentID = value; } get { return _parentID; } }
public string Alias { get { return _alias; } set { _alias = value; } }
public bool Save() {
//Code that will execute on creation //Get the type you would like to use by its alias //and the user who should be the creator of the document DocumentType dt = DocumentType.GetByAlias("Danceclass"); User author = User.GetUser(0);
//create a document with a name, a type, an umbraco user, and the ID of the document's parent page. //To create a document at the root of umbraco, use the id -1
Refreshing the detail panel after deleting node in custom tree
Hi,
I'm doing a custom tree/section and I'm implementing a customtasks.cs with tasks to fire when adding new nodes and deleting old ones.
The code for adding a new node works fine with the detail panel showing the content of the new node upon saving.
However, when deleting the detail panel still shows the content of the deleted node after execution. How do I get the detail panel to show other content?
Code shown below, the node's id is stored in the parentID property.
Best,
Johannes
using System;
using System.Collections.Generic;
using System.Web;
using System.Linq;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.cms.businesslogic.web;
using umbraco.BusinessLogic;
using umbraco.NodeFactory;
using umbraco.BasePages;
using umbraco.cms.businesslogic.member;
namespace CustomUmbracoSection.Tasks
{
public class CustomTasks : umbraco.interfaces.ITaskReturnUrl
{
private string _alias;
private int _parentID;
private int _typeID;
private int _userID;
public int UserId
{
set { _userID = value; }
}
public int TypeID
{
set { _typeID = value; }
get { return _typeID; }
}
public int ParentID
{
set { _parentID = value; }
get { return _parentID; }
}
public string Alias
{
get
{
return _alias;
}
set
{
_alias = value;
}
}
public bool Save()
{
//Code that will execute on creation
//Get the type you would like to use by its alias
//and the user who should be the creator of the document
DocumentType dt = DocumentType.GetByAlias("Danceclass");
User author = User.GetUser(0);
//create a document with a name, a type, an umbraco user, and the ID of the document's parent page.
//To create a document at the root of umbraco, use the id -1
Document doc = Document.MakeNew(this.Alias, dt, author, 1436);
doc.getProperty("name").Value = this.Alias;
//after creating the document, prepare it for publishing
doc.Publish(author);
//Tell umbraco to publish the document
umbraco.library.UpdateDocumentCache(doc.Id);
m_returnUrl = string.Format("editContent.aspx?id={0}", doc.Id.ToString());
return true;
}
public bool Delete()
{
//Code that will execute when deleting
Node n = new Node(this.ParentID);
Document doc = new Document(this.ParentID);
doc.delete();
//doc.XmlRemoveFromDB();
umbraco.library.RefreshContent();
m_returnUrl = "editContent.aspx?id=10000000";
return true;
}
public CustomTasks()
{
}
#region ITaskReturnUrl Members
private string m_returnUrl = "";
public string ReturnUrl
{
get { return m_returnUrl; }
}
#endregion
}
}
Found the solution here
http://blog.toxic.se/blog/2011/october/custom-section-moving-away-from-content-after-delete/
Thank you, Peter Josefson!
is working on a reply...