deleting a design + its css / template without any test :
as you can see we must remove "logically" the links between the design and the css/tpl even if we just remove physically the stuff in the database... ok why not even if it would be more logical to make a verification directly in the database in case of error "just to be sure" but i can understand that for the performances issues.$design = CmsLayoutCollection::load("Wiki Design With Foundation");
$css_all = $design->get_stylesheets();
foreach ($css_all as $css) {
try{
$css_obj = CmsLayoutStylesheet::load($css);
if($css_obj != null){$css_obj->delete();}
} catch (CmsDataNotFoundException $e){ echo "css ".$css." not found"; }
$design->delete_stylesheet($css);
}
$tpl_all = $design->get_templates();
foreach ($tpl_all as $tpl) {
try{
$tpl_obj = CmsLayoutTemplate::load($tpl);
if($tpl_obj != null){$tpl_obj->delete();}
} catch (CmsDataNotFoundException $e){ echo "template ".$tpl." not found"; }
$design->set_templates(array());
}
try{
$design->delete();
echo "<br/>design ".$design->get_name()." deleted";
} catch (CmsException $e){ echo "design ".$design->get_name()." cannot be deleted"; echo $e->getMessage();}
But if you can found in the apidoc a clear function delete_stylesheet, there is not function delete_template...
the workaround right now is to setting a empty array with set_templates(array()) ... it's not very consistent (IMHO)
one more time Calguy1000 : thank you for the works you done !