Codeigniter hmvc kickstart, support multi themes
@author: Sinh Quan
@email: [email protected], [email protected]
@description: Some notes when you using this codeigniter kickstar
Username and password to login: [email protected]/012345678
You can change this in ci_hmvc_kickstart/admin/modules/auth/models/auth_model.php
-
routes: http://localhost/mycq/module_name/controller_name/function_name
You can rerouts in: config/routes.php
Example:
//auth module $route['register'] = "auth/register/index"; => http://localhost/ci_hmvc_kickstart/register $route['register'] = "module_name/controller_name/function_name";
-
Using global var:
ci_hmvc_kickstart/application/core/Frontend_Controller.php
PHP:
$this->global_var can be call from any where in controller, call it in view by $view['global_var']Javascript: global_var is global in javascript, it assigned by $this->global_var
Example: global_var.base_url
-
javascript & css
If module using javascript carete file name as themes/themes_name/assets/js/module_name.js Writing in object, see themes/themes_name/assets/js/base.js for more detail
You can use follow code to add assets file in controler
//Automatic set js or css by file extension $this->template->add_asset('base.js'); $this->template->add_asset('style.css');
//can be use like this
$this->template->add_asset('http://maps.google.com/maps/api/js?sensor=true');
-
layout
You can create many layout as you wish themes/themes_name/layout/default_layout.php is main layout, themes/themes_name/layout/public_layout.php
-
Run other modules
$view = Modules::run('post/feed/index'); $view = Modules::run('ten_module/ten_controller/ten_function'); //return html to $view variable
-
template All view file should be have prefix: v, it will be ease to know which is controler or view if you open multi docs in IDE
Ex: login.php is controler, vlogin.php is view
Assign a variable from controler to view
$this->template->set('member', $arr_member_info);
To set html Title and Description or Keyword meta tag
$this->template->set_title("CI hmvc kick start with multi themes support"); $this->template->set_description("CI hmvc kick start with multi themes support"); $this->template->set_keyword("CI hmvc kick start with multi themes support");
To change layout in controller:(default is default_layout)
$this->template->set_layout("public_layout");
//Automatic set js or css by file extension
$this->template->add_asset('base.js'); $this->template->add_asset('style.css');
Call view in controller
$this->template->view('auth/vlogin'); $this->template->view('module_name/view_file_name_with_no_extension');
-
SQL should be in clear, easy to read and understand Ex:
$sql = "SELECT * FROM $this->tbl_name WHERE 1 ORDER BY id DESC LIMIT $offset, $limit"; $p_result = $this->db->query($sql)->result_array();
Just using
$this->db->query($sql) to get database result.