开发者

Specific Page Title For A Specific Page

开发者 https://www.devze.com 2023-03-18 01:48 出处:网络
At the present time I have my main page title set to the page name but for the homepage I would like to set it to a different \"title\" but I do not want to alter the \"title\" in the database as this

At the present time I have my main page title set to the page name but for the homepage I would like to set it to a different "title" but I do not want to alter the "title" in the database as this effects the URI and <title>. In the view I only want to change a singular h1 tag

Is there away that I can alter the following code with an if else statement to say if the page is = to home then show welcome else con开发者_JAVA百科tinue on and show the page names?

    public function index()
    {
        $page = $this->uri->segment(2, FALSE);
        if (!$page)
        {
            die(' wrong permalink in DB'); //show_404();
        }
        else
        {
            $page = $this->navigation_model->getCMSPageByPermalink($page);
            $data['cms_pages'] = $this->navigation_model->getCMSPages();
            $data['title'] = $page->name;
            $data['class'] = $page->permalink;

            // put all page templates in the 'views/templates' dir to keep it tidy
            // load in my whole page object, allows me to access the variables directly.
            $data['content'] = $this->load->view('templates/'. $page->template, $page, TRUE);

            $this->load->view('template',$data);
        }
    }
}


try this

$data['title'] = ($page->name == 'Home' ? 'Welcome' : $page->name);

0

精彩评论

暂无评论...
验证码 换一张
取 消