Codeigniter 3.0 相关文档 part one

分页配置项

http://stackoverflow.com/questions/18418900/codeigniter-pagination-config-without-repeating-within-different-controllersphp

相关工具

google搜索"codeigniter generator",会有几个自动化的工具
http://crudigniter.com/html

https://bitbucket.org/harviacode/codeigniter-crud-generatorapi

http://formigniter.org/数组

增长全局变量

config/constants.phpapp

增长站点配置项

在config目录下新建site_settings.php,在里面添加配置项:ide

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

$config['site_name'] = 'site name goes heere';
$config['site_description'] = 'site description';
$config['author'] = 'matt';
$config['author_site'] = 'matt';

在controller里加载配置并调用配置项函数

$this->config->load('site_settings',TRUE);
$site_name = $this->config->item('site_name');

若是你在使用 $this->config->load 方法时使用了第二个参数,每一个配置文件中的配置 被存储到以该配置文件名为索引的数组中,要获取该配置项,你能够将 $this->config->item() 方法的第二个参数设置为这个索引名(也就是配置文件名)。
Config Classcodeigniter

增长全局函数

若是是系统层面已有,作补充的,能够在system/helpers/xxx_helper.php添加
若是是彻底自定义的,能够application/helpers/添加工具

记得在autoload.php里引入fetch

$autoload['helpers'] = array('your-global-function-file.php');

全字段查询工具

https://datatables.net/examples/api/

为当前连接添加active样式

增长一个menu_helper的工具

<?php 
if(!defined('BASEPATH')) exit('No direct script access allowed');

if(!function_exists('active_link')) {
  function activate_menu($controller) {
    // Getting CI class instance.
    $CI = get_instance();
    // Getting router class to active.
    $class = $CI->router->fetch_class();
    return ($class == $controller) ? 'active' : '';
  }
}

在连接中使用

<li class="<?php echo activate_menu('login'); ?>">    
  <?php echo anchor('login', 'Login'); ?> 
</li>

参考资料

http://stackoverflow.com/questions/10831213/where-to-place-global-functions-in-codeigniter
http://codeigniter.org.cn/user_guide/general/index.html

相关文章
相关标签/搜索