JasonBaier / ci3-fire-starter

NOW THAT CODEIGNITER 4 HAS BEEN RELEASED, THIS PROJECT WILL NOT BE UPDATED ANYMORE. CI3 Fire Starter is a CodeIgniter3 skeleton application that includes jQuery and Twitter Bootstrap. It is intended to be light weight, minimalistic and not get in your way of building great CodeIgniter 3 applications.
MIT License
153 stars 152 forks source link

undefined variable ? #15

Closed ghost closed 9 years ago

ghost commented 9 years ago

hello first of all thanks for creating this starter kit, however when i create a new controller im getting this error

    Message: Undefined variable: page_header

    Filename: default/template.php

    Line Number: 76

my controller is like this


    class Movie extends Public_Controller {

        public function index() {
            // Check for login
            if (!$this->session->userdata('logged_in')) {redirect('/');}

            // Build Data for page
            $header_data['page_title'] = 'Main';

            // load views
            $data['content'] = $this->load->view('movie/top_menu', $header_data, TRUE);
            $this->load->view($this->template, $data);
        }
    }

cant figure out what i am doing wrong im new in php and codeigniter

ghost commented 9 years ago

oh its fixed by changing this

    // Build Data for page
    $header_data['page_title'] = 'Main';

to this

    // Build Data for page
    $header_data = array(
        'page_title' => 'Main',
        'page_header' => 'Welcome to CI3 Fire Starter',
    );

and changed Public_controller to Private_Controller so i dont need to use

if (!$this->session->userdata('loged_in')) {redirect('/');}

this kit is amazing thank you soo much

arif-rh commented 9 years ago

Hi @DeeJaVu

If you want to set title and page header, you can use set_title( $title ) and set_page_header( $page_header ) function, like this:

$this->set_title( 'Main' )->set_page_header( 'Welcome to CI3 Fire Starter' );
$data = $this->includes;

or if your title and page header have same text, you just use set_title( $title ); and then pass the variable into views.

// load views
$data['content'] = $this->load->view('movie/top_menu', $data, TRUE);
$this->load->view($this->template, $data);
ghost commented 9 years ago

ohh that makes sense now :) Thanks