gpt4 book ai didi

codeigniter - 将元数据从 Controller 添加到 codeigniter View

转载 作者:行者123 更新时间:2023-12-01 03:31:00 26 4
gpt4 key购买 nike

在我的 Controller 中,我添加了此代码。对于不同的 View 文件,有不同的功能。如何为不同 View 的不同功能添加元标记?
这是我的 Controller :

<?php
class home extends CI_Controller {



function index()
{
$data['meta_title'] = 'Tracenow | iOS Version';
$data['meta_description'] = 'Responsive HTML5 Theme in iOS Style';
$data['meta_keywords'] = 'responsive html5 theme, ios, android, material design, landing, application, mobile, blog, portfolio, bootstrap 3, css, jquery, flat, modern';
$data['meta_author'] = '8Guild';
$data['meta_viewport'] = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';
$this->load->view('home_page/home_page');


}

function about()
{
$this->load->view('home_page/about');

}

function blog()
{
$this->load->view('home_page/blog');

}

function blog_single()
{
$this->load->view('home_page/blog-single');

}


}
?>

最佳答案

For this you can simply use this in your controller:

$data['meta_title'] = 'Your meta title';
$data['meta_description'] = 'Your meta description';
$data['meta_keywords'] = 'Your meta keywords';

And you view should be like:

<title><?php echo $meta_title; ?></title>
<meta name="description" content="<?php echo $meta_description; ?>" />
<meta name="keywords" content="<?php echo $meta_keywords; ?>" />

希望它会帮助你。或者如果您需要任何帮助,请在下面发表评论。

关于codeigniter - 将元数据从 Controller 添加到 codeigniter View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37653199/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com