我是 codeigniter 的新手,我不是该项目的第一个 Web 开发人员,但是我在 views 文件夹中发现它有 template.php 可以加载到所有页面中。如何覆盖加载 template.php 标头的视图文件夹内标头的元数据?我希望它有不同的元数据。
这是 Template.php 的代码
<title>I Sold My Business - Your one-stop shop for online business brokerage</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="description" content="Whether you’re an entrepreneur trying to buy a business online or a broker who wants to sell businesses, I Sold My Business is here to help you. Visit us today!">
<meta name="keywords" content="sold business online, buy business online, sell business online">
<?php echo @$template['framework']; ?>
<?php echo @$template['bootstrap']; ?>
<?php echo @$template['head']; ?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('templates/site/reconvert_style.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('templates/site/stylesheet.css'); ?>" />
<script type='text/javascript'>
(function (d, t) {
var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];
bh.type = 'text/javascript';
bh.src = '//www.bugherd.com/sidebarv2.js?apikey=rkdoxsrzmxvrsrt6ailjsa';
s.parentNode.insertBefore(bh, s);
})(document, 'script');
</script>
这是控制器文件夹 home.php 中的代码
类 Home 扩展 CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('business_category_model');
$this->load->model('franchise_category_model');
$this->load->model('account_model');
$this->load->model('country_model');
}
public function index()
{
$template = array();
$template['title'] = "Home";
$this->load->model(array('business_listing_model', 'featured_business_model', 'franchise_model'));
$this->load->helper('text');
$page = array();
$page['countries'] = $this->country_model->get_all();
$featured_businesses = $this->featured_business_model->random(3);
$featured_count = 0;
foreach($featured_businesses->result() as $index => $featured_business)
{
if($featured_business->type == 'business' || $featured_business->type == 'video')
{
$page['featured_businesses'][$featured_count] = (array) $this->business_listing_model->get_one($featured_business->business_id);
}
else
{
$page['featured_businesses'][$featured_count] = (array) $this->franchise_model->get_one($featured_business->business_id);
}
$page['featured_businesses'][$featured_count]['f_type'] = $featured_business->type;
$featured_count++;
}
if($featured_businesses->num_rows() < 3)
{
$limit = 3 - $featured_businesses->num_rows();
$random_business = $this->business_listing_model->get_random($limit);
foreach($random_business->result() as $index => $featured_business)
{
$page['featured_businesses'][$featured_count] = (array) (array) $this->business_listing_model->get_one($featured_business->business_listing_id);
$page['featured_businesses'][$featured_count]['f_type'] = 'business';
$featured_count++;
}
}
$page['business_categories'] = $this->business_category_model->get_all('', array('business_category_title' => 'asc'));
$page['franchise_categories'] = $this->franchise_category_model->get_all();
$template['content'] = $this->template->get_view('home', $page, 'site');
$this->template->render($template, 'site');
}
public function sell_your_biz()
{
$username = $this->session->userdata('username');
$account_type = $this->session->userdata('account_type');
$account = $this->account_model->get_by_username($username);
if(strlen($username)==0)
{
$this->template->notification('Please login or create an account to post a listing', 'error');
redirect('/login/');
}
$template = array();
$template['title'] = "Sell Your Biz";
$page = array();
$template['content'] = $this->template->get_view('sell_your_biz', $page, 'site');
$this->template->render($template, 'site');
}
public function view_reconvert()
{
$template = array();
$template['title'] = "Home";
$page = array();
$page['countries'] = $this->country_model->get_all();
$page['business_categories'] = $this->business_category_model->get_all();
$page['franchise_categories'] = $this->franchise_category_model->get_all();
$template['content'] = $this->template->get_view('home2', $page, 'site');
$this->template->render($template, 'site' , 'template_rconvert');
}
}