Page 1 of 1

how to create a stylesheet

Posted: Mon May 19, 2014 10:44 pm
by Jos
In a pre 2.0 setup, one could create a stylesheet with this piece of code.

Code: Select all

// setup sample stylesheet
$stylesheetops = cmsms()->GetStylesheetOperations();
$fn = cms_join_path(dirname(__FILE__), 'templates', 'stylesheet.css');
if( !$stylesheetops->CheckExistingStylesheetName('nameofstylesheet') && file_exists($fn) )
{
        $stylesheet = new Stylesheet();
        $stylesheet->name = 'nameofstylesheet';
        $stylesheet->value = @file_get_contents($fn);  
        $stylesheet->media_type = 'screen';
        $stylesheetops->InsertStylesheet($stylesheet);
}
This does not work anymore in 2.0 beta.
I have searched the 2.0 API docs for more than an hour, but seem to have looked in all the wrong places.

How to rewrite the above code so it will work in 2.0?

Re: how to create a stylesheet

Posted: Mon May 19, 2014 11:31 pm
by calguy1000
$txt = file_get_contents($some_file);
$css = new CmsLayoutStylesheet;
$css->set_name('Some Stylesheet Name');
$css->set_description('A nice description for the stylesheet');
$css->set_content($txt);
$css->save();

Reference: http://www.cmsmadesimple.org/APIDOC2_0/ ... sheet.html