[fixed] Missing function into class.CmsLayoutCollection.php

Forum rules
Only administrators can post or move items here.
Post Reply
bess
Language Partners
Language Partners
Posts: 282
Joined: Thu Dec 18, 2008 9:37 am
Location: Bretagne

[fixed] Missing function into class.CmsLayoutCollection.php

Post by bess »

as i playing with the installation of design with my modules (very nice stuff btw) i founded this surprise :

deleting a design + its css / template without any test :
$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();}
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.

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 !
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: [Minor] Missing function into class.CmsLayoutCollection.

Post by calguy1000 »

Well, when calling $stylesheet->delete() or $template->delete() we delete the template/stylesheet from all designs the opposite is not true.

A stylesheet or a template is only optionally attached to one or more designs.

However, you are right. And I've added the method for deleting a template, and also fixed some issues with delete_stylesheet().
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
bess
Language Partners
Language Partners
Posts: 282
Joined: Thu Dec 18, 2008 9:37 am
Location: Bretagne

Re: [Minor] Missing function into class.CmsLayoutCollection.

Post by bess »

thank you ;)
Post Reply

Return to “Closed Issues”