一.在项目配置中加入titleConfig.php
<?php
$title['user']= array('memberlist' => '用户管理-用户信息列表',
'setUserVip' => '用户管理-设置vip用户',
'financereportlist' => '用户管理-财务报告列表',
'findpassword' => '用户管理-找回密码',
'sensitive' => '用户管理-敏感词过滤',
'logmodifyinfolist' => '用户管理-修改资料日志',
'logcanceloperatelist' => '用户管理-取消操作保护日志',
'logloginlist/history' => '用户管理-2014年之前用户登录日志',
'loginipcountlist' => '用户管理-IP登陆次数统计',
'getsafeaddress' => '用户管理-常用地址',
'memberdateextlist' => '用户管理-用户信息变更日志'
);
//财务管理
$title['finance'] = array(
'index' => '财务管理-查看用户财务信息',
'financelist' => '财务管理-财务列表',
'financein' => '财务管理-入款流水帐',
'financeout' => '财务管理-出款流水帐',
'financeorder' => '财务管理-续费订单管理',
'financelog' => '财务管理-财务日志',
'manconfirmorder' => '域名管理-批量确认订单',//域名管理
);
二.在公共函数中加入,然后在需要的地方直接调用该静态方法即可:
{
require_once APPPATH . 'config/titleconfig.php'; //将配置文件中的标题配置引入
$default_title = '后台系统';
$head_title = '';
if($query_string)
{
$str = preg_split("/[\&=\?\/#]+/", $query_string);
$data = array();
foreach($str as $key => $value)
{
if($value == 'index.php' || $value == '')
{
unset($str[$key]);
}
if($value == 'c')
{
$data['controllers'] = $str[$key + 1];
}
elseif($value == 'm')
{
$data['method'] = $str[$key + 1];
}
}
$str = array_merge($str);
if($data)
{
$str[0] = $data['controllers'];
$str[1] = $data['method'];
}
if(count($str) == 1) // 一个参数
{
if(isset($no_set_query[$str[0]]))
{
$head_title = $no_set_query[$str[0]];
}
}
if(count($str) >= 2 && isset($title[$str[0]][$str[1]])) // 两个参数
{
$head_title = $title[$str[0]][$str[1]];
}
if(count($str) >= 3) // 三个参数,第二个与第三个用"/"或"#"连接
{
$second = $str[1] . '/' . $str[2];
if(isset($title[$str[0]][$second]))
{
$head_title = $title[$str[0]][$second];
}
else
{
$second = $str[1] . '#' . $str[2];
if(isset($title[$str[0]][$second]))
{
$head_title = $title[$str[0]][$second];
}
}
}
}
return $head_title ? $head_title : $default_title;
}
三.在相关的文件调用
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title><?php require_once SYSTEM_LIB_PATH . 'lib/common/Title.php';echo Title::getTitle($_SERVER['REQUEST_URI']);?></title>
</head>