[英]CodeIgniter title won't work
I understand an approach to naming declaring a title for a page in CI can be done like this, which has in the past and if anything within an existing project works. 我了解一种命名CI声明页面标题的方法可以像过去那样完成,而在现有项目中是否可行。
$data['title'] = "myTitle";
$this->load->view("content_home", $data);
But for the life of me, now it just will not work!! 但是对于我的一生来说,现在它根本行不通了!! :(
:(
Anybody any ideas as to why? 有人对为什么有任何想法吗?
In order to declare a title to a page, you type this in the controller relevant to a page example: 为了声明页面标题,请在与页面示例相关的控制器中键入以下内容:
public function home(){
$data["title"] = "my Title";
$this->load->view("content_home", $data);
}
Within the view in order for this to work this must be inserted: 为了使其正常工作,必须在视图中插入:
<title><?php echo $title; ?></title>
I had not realised, but this worked for me now after I went back and checked my files properly in my previous project, sorry guys and thanks for the responses. 我没有意识到,但是当我返回并在之前的项目中正确检查了我的文件之后,现在对我有用,对不起,谢谢您的答复。
just fyi you can check if title has been set and if not show something else 仅供参考,您可以检查标题是否已设置,如果未显示其他内容
<title><?php
// check if $title has been set
if( isset($title) ){ echo $title; }
// else display generic title
else { echo "A Website Title" ; }
?></title>
that way you will always be covered 这样,你将永远被覆盖
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.