Welcome Guest, Not a member yet? Register   Sign In
Issue defining variables in constructor
#1

[eluser]soarchrist[/eluser]
I am really lost on this one. I've read about it here and there... and have seen "examples" of how this should work.

The goal is to define the page title in the __construct() for ALL functions of the controller. In the view file "header", it just calls "echo @$title;"

What am I doing wrong?

Code:
class Contacts extends Controller {
    
    
    function __construct()
    {
        parent::Controller();
            
        $this->$data['title'] = 'Contacts Management';
        
        
    }
    
    function index()
    {
        
        $this->load->view('header');
        $this->load->view('loginbox');
        $this->load->view('menu');
        $this->load->view('awantay/contacts');
        $this->load->view('footer');
    }

Not only is the title NOT displayed in the page header, but actually errors out saying:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined variable: data

Filename: awantay/contacts.php

Line Number: 17

Fatal error: Cannot access empty property in C:\xampp\xampplite\htdocs\system\application\controllers\awantay\contacts.php on line 17

Line 17 refers to the line in the __construct:

Code:
$this->$data['title'] = 'Contacts Management';

ANY help is greatly appreciated.


Messages In This Thread
Issue defining variables in constructor - by El Forum - 02-12-2010, 09:12 PM
Issue defining variables in constructor - by El Forum - 02-12-2010, 10:02 PM
Issue defining variables in constructor - by El Forum - 02-13-2010, 03:54 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 05:02 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 07:42 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 10:25 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 10:52 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 11:27 AM
Issue defining variables in constructor - by El Forum - 02-13-2010, 12:04 PM
Issue defining variables in constructor - by El Forum - 02-14-2010, 05:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB