我做到了,但试图通过' pre_controller'添加和' pre_system'钩而不工作。
类
class seo_metas
{
public function __constructor() {
$SEOMetas['descripcion'] = "";
$SEOMetas['keywords'] = "";
$SEOMetas['title'] = "";
$SEOMetas['subtitle'] = "";
$SEOMetas['author'] = "";
$SEOMetas['charset'] = "utf-8";
}
public function get_seo_metas() {
$SEOMetas['descripcion'] = "";
$SEOMetas['keywords'] = "Dev";
$SEOMetas['title'] = "SM";
$SEOMetas['subtitle'] = "Dev";
$SEOMetas['author'] = "Sam";
$SEOMetas['charset'] = "utf-8";
}
public function set_seo_metas($descripcion, $keywords, $title, $subtitle, $author, $charset) {
$SEOMetas['descripcion'] = $descripcion;
$SEOMetas['keywords'] = $keywords;
$SEOMetas['title'] = $title;
$SEOMetas['subtitle'] = $subtitle;
$SEOMetas['author'] = $author;
$SEOMetas['charset'] = $charset;
}
}
挂钩
$hook['pre_controller'][] = array(
'function' => 'get_seo_metas',
'filename' => 'seo_metas',
'filepath' => 'hooks'
);
标题
<meta charset=<?php echo $SEOMetas['charset']?> />
<title><?php ($SEOMetas['title'] . $SEOMetas['subtitle'] )?> </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content=<?php echo $SEOMetas['author']?> />
<meta name="description" content=<?php echo $SEOMetas['author']?> />
<meta name="keywords" content=<?php echo $SEOMetas['keyworkds']?> />
非常感谢!