I use the codeigniter framework for my web project. My question is how to install multiple template templates and the base path for assets like css, js and images? I want to configure the interface, login and rear end. So there are 3 layouts that I need to customize.
My project structure

This is sample code for my project.
MY_Controller.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class My_Controller extends CI_Controller {
protected $layout = 'admin';
protected $stylesheets = array(
'app.css'
);
protected $javascripts = array(
'app.js'
);
protected function render($content) {
$view_data = array(
'content' => $content,
'stylesheets' => $this->get_stylesheets(),
'javascripts' => $this->get_javascripts()
);
$this->load->view($this->layout,$view_data);
}
protected function get_stylesheets() {
return $this->stylesheets;
}
protected function get_javascripts() {
return $this->javascripts;
}
}
home.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends My_Controller {
public function index() {
$content = $this->load->view('home/index',null,true);
$this->render($content);
}
}
?>
I found this link on the Internet, but is not suitable for my project. http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html
source
share