Welcome Guest, Not a member yet? Register   Sign In
Setting variables to be used controller wide.
#1

[eluser]uber_n00b[/eluser]
I want to setup a variable to be used by various functions in my controller. I have viewed one of the posts on here that offered a few suggestions but it was dealing with strings and not arrays.

How can I make $timezone_drop; available to all functions in my class/controller?

Code:
$timezone_drop = array(
       '' => 'Select Timezone',
        1 => 'Eastern',
        2 => 'Central',
        3 => 'Mountain',
        4 => 'Pacific',
        5 => 'Alaskan',
        6 => 'Hawaiian',
    );

I have tried placing it in my construct function
Code:
function __construct()
{
parent::__construct();

    $timezone_drop = array(
       '' => 'Select Timezone',
        1 => 'Eastern',
        2 => 'Central',
        3 => 'Mountain',
        4 => 'Pacific',
        5 => 'Alaskan',
        6 => 'Hawaiian',
    );
}
function index(){ $this->data['timezone'] = $timezone_drop; }

index() will throw an error saying $timezone_drop is undefined however if I place the variable declaration in index() it works fine.

Please help.

Thanks!


Messages In This Thread
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 01:11 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:33 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:45 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 02:58 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 03:50 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 03:58 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 04:02 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 04:15 PM
Setting variables to be used controller wide. - by El Forum - 06-19-2012, 05:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB