loadCss Method

The loadCss method purpose is for loading css file from a controller.

Basic Usage

Here is the basic usage loadCss method from SENE_Controller class.

$this->loadCss(string $src[, string $utype]): $this

Parameters

loadCSS has 1 required parameter and 1 optional parameter.

$src

The $src value can be an relative url by using base_url() function or using CDN url by using cdn_url() method or a plain external URL.

$utype

The $utype value indicates the load position of css after load. Here is the list of compatible values:

  • before, its mean css will be loaded before theme.json list.
  • after, its mean css will be loaded after theme.json list.

Example Usage

Here is the full example for loadCss method by using used external css resource.

$this->loadCss('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css','before');

Relative CSS File

If want to used relatives css resource, simply use.

$this->loadCss(base_url('assets/css/font-awesome.min.css','before'));

Full Example

Here is the full example on blog.php file controller.

<?php
class Blog extends SENE_Controller {
  public function __construct(){
    parent::__construct();
  }
  public function index(){
    //external
    $this->loadCss('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css','before');
    //relatives
    $this->loadCss(base_url('assets/css/font-awesome.min.css','before'));

    //theme content and layout rendering
    $this->putJSReady('home/home_bottom',$data);
    $this->putThemeContent('home/home',$data);
    $this->loadLayout('col-1',$data);
    $this->render();
  }
}

Caution

Please make sure this method has been loaded from header html template, with the following order: