Codeigniter 3.0 相关文档 part one

简介: 分页配置项http://stackoverflow.com/questions/18418900/codeigniter-pagination-config-without-repeating-within-different-controllers相关工具google搜索"codeigniter generator",会有几个自动化的工具http://crudigniter.

分页配置项

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

相关工具

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

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

http://formigniter.org/

增加全局变量

config/constants.php

增加站点配置项

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

<?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 Class

增加全局函数

如果是系统层面已有,做补充的,可以在system/helpers/xxx_helper.php添加
如果是完全自定义的,可以application/helpers/添加

记得在autoload.php里引入

$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

相关文章
|
8月前
|
API
使用 Schematics 创建的 Spartacus Storefront,在 index.html 里指定 OCC API url
使用 Schematics 创建的 Spartacus Storefront,在 index.html 里指定 OCC API url
42 0
|
1天前
|
存储 API
使用Webpack的module.hot API来定义模块的热替换
使用Webpack的`module.hot` API实现模块热替换,简单示例展示如何在`myModule`变化时执行回调。`module.hot.accept`接收模块路径和回调函数,当模块或其依赖变更时触发回调,用于执行更新逻辑。可通过`module.hot.data`保存和恢复状态以实现热替换时保持应用程序的状态。
|
12月前
|
开发框架 移动开发 前端开发
如何使用C#和HTMLAgilityPack抓取网页
HTMLAgilityPack是一款备受欢迎的用于解析和操作HTML文档的库。在使用之前,开发者需要考虑一些优缺点。下面是一些值得注意的优点: 1. 强大的错误容忍性 2. 灵活的API 3. 广泛的应用场景 然而,也有一些缺点需要考虑: 1. 性能问题 2. 对最新HTML特性的支持限制 3. 可能存在依赖和冲突
|
前端开发 API
webpack配置篇(三十八):语义化版本(Semantic Versioning)规范格式
webpack配置篇(三十八):语义化版本(Semantic Versioning)规范格式
85 0
webpack配置篇(三十八):语义化版本(Semantic Versioning)规范格式