php - CodeIgniter - Page variables undefined in view -


i'm bit baffled. i'm pretty sure working before, but…

this pretty basic scenario. page variables defined in controller via $data, reason they're not available in view. unless i'm going blind can't see wrong code.

controller function (in full ultimate clarity):

function login() {     $data['page_title'] = 'login title';     $data['page_description'] = 'login description';     $data['page_keywords'] = 'login,keywords';     $data['referer'] = $this->session->flashdata('referer');      if($this->input->post('email',true) !== false)     {         $this->form_validation->set_rules('email', 'email', 'trim|required|xss_clean');         $this->form_validation->set_rules('password', 'password', 'trim|required|xss_clean|callback_check_password');          if($this->form_validation->run() == false)         {             // log failed attempt against ip address             $this->bruteforce->log_fail( $this->input->ip_address() , $this->input->post('email',true) );         }         else         {             // go accounts home             if($this->input->post('referer') != '')             {                 redirect($this->input->post('referer'));             }             else             {                 redirect('dashboard');             }          }     }      $this->load->view('login_view',$data); } 

so on normal page load controller set variables , load view.

the view (up until point of failure) looks so:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en"  "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">  <!-- meta --> <title><?php echo $page_title; ?></title> 

however i'm getting:

message: undefined variable: page_title

any ideas? :s

edit:

ok discovered odd.

i'm viewing above view default controller, www.domain.com. if view going directly url, in case: www.domain.com/access/login/ works fine. i'm not sure why make difference, seems root of cause. in both scenarios same controller being loaded. i'm still baffled.

edit 2: see answer below. wrong controller loading, controller shouldn't have existed anymore still being referenced couple of important functions. doh.

try use

function login() {     $data['page_title'] = 'login title';     $data['page_description'] = 'login description';     $data['page_keywords'] = 'login,keywords';     $data['referer'] = $this->session->flashdata('referer');      if($this->input->post('email'))     {         $this->form_validation->set_rules('email', 'email', 'trim|required|xss_clean');         $this->form_validation->set_rules('password', 'password', 'trim|required|xss_clean|callback_check_password');     }         if($this->form_validation->run() == false)         {             // log failed attempt against ip address             $this->bruteforce->log_fail( $this->input->ip_address() , $this->input->post('email',true) );            $this->load->view('login_view',$data);         }         else         {             // go accounts home             if($this->input->post('referer') != '')             {                 redirect($this->input->post('referer'));             }             else             {                 redirect('dashboard');             }          }  } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -