addCSS() public method

If you don't specify a module, the current one will be used to automatically create the path to the file. Automatic creation of the filename will result in src/Backend/Modules/MODULE/Layout/Css/FILE (for modules) src/Backend/Core/Layout/Css/FILE (for core) If you set overwritePath to true, the above-described automatic path creation will not happen, instead the file-parameter will be used as path; which we then expect to be a full path (It has to start with a slash '/')
public addCSS ( string $file, string $module = null, boolean $overwritePath = false, boolean $minify = true, boolean $addTimestamp = false )
$file string The name of the file to load.
$module string The module wherein the file is located.
$overwritePath boolean Should we overwrite the full path?
$minify boolean Should the CSS be minified?
$addTimestamp boolean May we add a timestamp for caching purposes?
Example #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // add jquery, we will need this in every action, so add it globally
     $this->header->addJS('jquery/jquery.js', 'Core', false);
     $this->header->addJS('jquery/jquery.ui.js', 'Core', false);
     $this->header->addJS('jquery/jquery.ui.dialog.patch.js', 'Core');
     $this->header->addJS('jquery/jquery.tools.js', 'Core', false);
     $this->header->addJS('jquery/jquery.backend.js', 'Core');
     // add items that always need to be loaded
     $this->header->addJS('utils.js', 'Core');
     $this->header->addJS('backend.js', 'Core');
     // add module js
     if (is_file($this->getBackendModulePath() . '/Js/' . $this->getModule() . '.js')) {
         $this->header->addJS($this->getModule() . '.js');
     }
     // add action js
     if (is_file($this->getBackendModulePath() . '/Js/' . $this->getAction() . '.js')) {
         $this->header->addJS($this->getAction() . '.js');
     }
     // add core css files
     $this->header->addCSS('reset.css', 'Core');
     $this->header->addCSS('jquery_ui/fork/jquery_ui.css', 'Core', false, false);
     $this->header->addCSS('screen.css', 'Core');
     $this->header->addCSS('debug.css', 'Core');
     // add module specific css
     if (is_file($this->getBackendModulePath() . '/Layout/Css/' . $this->getModule() . '.css')) {
         $this->header->addCSS($this->getModule() . '.css');
     }
     // store var so we don't have to call this function twice
     $var = array_map('strip_tags', $this->getParameter('var', 'array', array()));
     // is there a report to show?
     if ($this->getParameter('report') !== null) {
         // show the report
         $this->tpl->assign('report', true);
         // camelcase the string
         $messageName = strip_tags(\SpoonFilter::toCamelCase($this->getParameter('report'), '-'));
         // if we have data to use it will be passed as the var parameter
         if (!empty($var)) {
             $this->tpl->assign('reportMessage', vsprintf(BL::msg($messageName), $var));
         } else {
             $this->tpl->assign('reportMessage', BL::msg($messageName));
         }
         // highlight an element with the given id if needed
         if ($this->getParameter('highlight')) {
             $this->tpl->assign('highlight', strip_tags($this->getParameter('highlight')));
         }
     }
     // is there an error to show?
     if ($this->getParameter('error') !== null) {
         // camelcase the string
         $errorName = strip_tags(\SpoonFilter::toCamelCase($this->getParameter('error'), '-'));
         // if we have data to use it will be passed as the var parameter
         if (!empty($var)) {
             $this->tpl->assign('errorMessage', vsprintf(BL::err($errorName), $var));
         } else {
             $this->tpl->assign('errorMessage', BL::err($errorName));
         }
     }
 }