#
tigermain
If you are trying to delete a non-node specific section, there is an error as the current code does not remove the section from any attached templates (have not tested with nodes), here is the change that I have implemented to fix this issue
\Web\Admin\Sections.aspx.cs
private void rptSections_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
{
int sectionId = Int32.Parse(e.CommandArgument.ToString());
Section section = (Section)base.CoreRepository.GetObjectById(typeof(Section), sectionId);
if (e.CommandName == "Delete")
{
try
{
// First tell the module to remove its content.
ModuleBase module = this.ModuleLoader.GetModuleFromSection(section);
module.DeleteModuleContent();
// Remove from all template sections
IList templates = this.CoreRepository.GetTemplatesBySection(section);
foreach (Template template in templates)
{
string attachedPlaceholderId = null;
foreach (DictionaryEntry entry in template.Sections)
{
if (entry.Value == section)
{
attachedPlaceholderId = entry.Key.ToString();
break;
}
}
template.Sections.Remove(attachedPlaceholderId);
base.CoreRepository.UpdateObject(template);
}
// Now delete the Section.
base.CoreRepository.DeleteObject(section);
}
catch (Exception ex)
{
ShowError(ex.Message);
log.Error(String.Format("Error deleting section : {0}.", section.Id.ToString()), ex);
}
}
BindSections();
}
}