私は 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');
}
}