CodeIgniter Forums

Full Version: Edit Page Issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8

El Forum

[eluser]jzmwebdevelopement[/eluser]
[quote author="toopay" date="1303200034"][quote author="jzmwebdevelopement" date="1303191727"]
I get the following error:

Code:
PHP Fatal error:  Call to a member function getCMSPage() on a non-object in controllers/home.php on line 22
[/quote]

i've just noticed, the error is in your home controller! Post it here.[/quote]

Code:
<?php
/**
*This controller holds the login checks and processing information
*function index = When someone goes to /admin they get sent to the login page
*function login = loads the login page style checks for validation & runs the querys if the content is valid
*function logout = unsets the session
     */

if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

    function __construct(){
        parent::__construct();
    }
    
    function index(){

        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        $data['cms_pages'] = $this->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);

    }
    public function login() {
        
        $this->form_validation->set_rules('username','Username', 'required|valid_email|trim|max_length[99]|xss_clean');
        $this->form_validation->set_rules('password','Password', 'required|trim|max_length[200]|xss_clean|callback__checkUsernamePassword');

        if($this->form_validation->run() === TRUE) {
        // set CLEAN data in the session.
            redirect('admin/dashboard');
        }
    
        $this->index();
    }
    
    function logout() {
        
        $this->session->sess_destroy();
        $this->index();
        
    }


    public function _checkUsernamePassword() {
        // adding the _ makes the function 'private' so it can't be called from the URI.
        
            extract($_POST); // Gets data from form and creates vars
            // this function might want to return ALL user data for this user, so you can set more info in the session, like, your name :)
            // but you cant get the data from out side of the callback, so maybe your right, and set the session inside of teh call back.
            
            $user = $this->login_model->check_login($username,$password);

            if(! $user){ // != If username or password are not correct
                $this->session->set_flashdata('login_error',TRUE); //does not add the non valid login to the session
                $this->form_validation->set_message('_checkUsernamePassword', 'Sorry %s is not correct.');
                return FALSE;

            } else {
                // you are setting the session in the next step, + the next step will have 'prep'd data after the form validation has run.                
                $this->session->set_userdata('logged_in',TRUE);
                $this->session->set_userdata('user_id',$user->id);
                $this->session->set_userdata('user_name',$user->first_name); // do these feilds exists in the datasbe >?
                $this->session->set_userdata('user_email',$user->email);
                return TRUE;
            
            }

    }
}

/* End of file home.php */
/* Location: ./application/controllers/admin/home.php */

El Forum

[eluser]toopay[/eluser]
change every 'function' into 'public function', if you need to limiting some function in it's scope use 'protected function' instead 'function'
Code:
public function index(){

        if($this->session->userdata('logged_in')) redirect('admin/dashboard');
        // set data
        $this->load->model('navigation_model');
        $data['title'] = 'Login';
        $data['sales_pages'] = NULL;
        $data['get_images'] = NULL;
        $data['cms_pages'] = $this->navigation_model->getCMSPages();

        // load partial view - EAMPLE
        // view path,  data to pass in ( NULL, array or object ), TRUE returns as a varialble, else echo's.
        $data['content'] = $this->load->view('admin/admin_login', NULL, TRUE);
        // THEN load view.
        $this->load->view('template', $data);

    }

El Forum

[eluser]jzmwebdevelopement[/eluser]
I have done this still no luck:

Is this correct for the __construct?

Code:
public function __construct() {
    parent::__construct();
    
    }

El Forum

[eluser]toopay[/eluser]
Its ok for __construct.

Are you sure you already loaded it manually from home controller like :
Code:
$this->load->model('navigation_model');
before call it's function?

The error you face, means one thing : the model isn't loaded yet, so it's function is undefined. And how you named the model file? is it Uppercase or lowercase?

El Forum

[eluser]jzmwebdevelopement[/eluser]
Yes I have,

I have also copied and pasted the file name from the model $this->navigation_model->blah to make sure the spelling is correct,

still no luck

El Forum

[eluser]toopay[/eluser]
How you named the model's file? is it Uppercase or lowercase?

El Forum

[eluser]jzmwebdevelopement[/eluser]
lower case navigation_model.php class Navigation_model

El Forum

[eluser]toopay[/eluser]
above 'Fatal error: Call..bla..bla', what it's error "Message" said.

El Forum

[eluser]jzmwebdevelopement[/eluser]
Sorry I do not understand your question

El Forum

[eluser]toopay[/eluser]
Is there a box, contain 4 paragraph text, above ‘Fatal error: Call[..bla..bla]’. If yes, what it's "Message" property (it should at paragraph 2) value.
Pages: 1 2 3 4 5 6 7 8