General CodeIgniter Header

I am very new to CodeIgniter, but I think I understand how this works.

Usually, when I create a site, for example a 5-page site, I have a header file in the php file that is included on each page, so if I need to change the title, I need to do this in only one instead of changing it to five time.

In my CodeIgniter application, I have a function for each page of my controller that loads a different view, depending on the function. For instance,

    public function Index() {

    $data = array();
    $this->load->view('index',$data);

}

public function blog() {

    $data = array();
    $this->load->view('inner1',$data);

}

Then I can put all my logic in the controller.

What is the best way to have one link title? Should I put it in the controller as a variable and then send it as data for each view?

Also, if there is a more efficient way to do this, suggest it!

Thank!

+3
3

, , , ... .

- :

public function blog() {

   $data = array();
   $this->load->view('Header'); // just the header file
   $this->load->view('inner1',$data); //your main content
}

?

: , , , , css .. , .

+5

CodeIgniter . /common my/views. footer.php, sidebar.php, header.php ..

:

$this->load->view('header');
<div id"main">
.....
</div>


$this->load->view('footer');

:

public function blog() {
   $this->data['title'] = "Blog";
   $this->data['meta_tags'] = $meta;
   $this->data['entries'] = $entries;

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

, $title $meta, . , common/header.php .

!

PD: Carabiner , header.php

+5

- ?

http://williamsconcepts.com/ci/codeigniter/libraries/template/

http://philsturgeon.co.uk/index.php/code/codeigniter-template

This will allow you to create a master template (or more if you need), where you could make changes to the site in a single file. These changes may include a heading, but they may include other regions.

+1
source

Source: https://habr.com/ru/post/1778332/


All Articles