how to create a stylesheet

A forum for module developers to discuss how to convert their modules to be compatible with CMSMS 2.0. Please read the APIDOC at http://www.cmsmadesimple.org/APIDOC2_0/
Post Reply
Jos
Support Guru
Support Guru
Posts: 4017
Joined: Wed Sep 05, 2007 8:03 pm
Location: The Netherlands

how to create a stylesheet

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

Re: how to create a stylesheet

Post 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
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.
Post Reply

Return to “Module Developers”