loadCss method

SENE_Controller::loadCSs is method for loading css from an URL in a controller.

Parameters

loadCSS has 2 parameters, there are $src dan $utype.

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

$src

Value for $src can be an relative url by using base_url() or using CDN url by using SENE_Controller::cdn_url or a plain external URL.

So, if want to used external css resource, simply use $this->loadCss('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css','before')

Or with relative css URL by using base_url, simply use this $this->loadCss(base_url('assets/css/font-awesome.min.css','before'));.

$utype

The value of $utype can be 'before' or 'after' or '' (empty string).

If value equal to before, its mean css will be loaded before app/view/THEME_NAME/theme.json list.

Or if value equal to after, its mean css will be loaded after app/view/THEME_NAME/theme.json list.

Full Example

Here is the full example for loadCss method:

<?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 template:

  • <?php $this->getAdditionalBefore()?>
  • <?php $this->getAdditional()?>
  • <?php $this->getAdditionalAfter()?>