Welcome Guest, Not a member yet? Register   Sign In
Variable Scope - Class Wide Variable
#3

[eluser]Unknown[/eluser]
Thanks Yorick,

Had a play with your suggestion, but got an error when using private $data;, but not when using var $data;

Looked into it, and realised it's because my server's running PHP4.

Also, putting the code in the __construct() function didn't work, but again figured that was a PHP5 thing.

Converted to PHP4 and it works a treat.

Categories Controller Code:

Code:
class Categories extends Controller {

var $data;

function Categories()
    {
        parent::Controller();
        $this->data['categories'] = $this->MCategories->getAllCategories();
    }


function index()
    {
        $this->data['content'] = "v_homepage";
        $this->data['title'] = "Product Categories";
        $this->data['homeProducts'] = $this->MProducts->getRandomProducts(6);
        
        $this->load->view('v_template',$this->data);
    }

}

Many thanks


Messages In This Thread
Variable Scope - Class Wide Variable - by El Forum - 10-03-2009, 07:58 AM
Variable Scope - Class Wide Variable - by El Forum - 10-03-2009, 09:25 AM
Variable Scope - Class Wide Variable - by El Forum - 10-03-2009, 10:38 AM
Variable Scope - Class Wide Variable - by El Forum - 10-03-2009, 12:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB