Welcome Guest, Not a member yet? Register   Sign In
How to initialize variable array as public?
#1

[eluser]anna16[/eluser]
Hi guys

I have this simple problem.
Every time i call a view file in each function i created,
I always initialized these variables.

example;
Code:
function email_userpass()
{
  $data = Array();
  $data['email'] = '';
  $data['error_message'] = '';
    
  $this->load->view('template/email_userpass-template', $data);
}

How do i simplify this? So that all the methods that needs these
variables will use these variables without re-declaring them again and again?

Thank in advanced.
#2

[eluser]SPeed_FANat1c[/eluser]
I guess this should help you: http://ellislab.com/forums/viewthread/175239/
#3

[eluser]anna16[/eluser]
@speed-fanatic

Thank you very much.
#4

[eluser]pickupman[/eluser]
That was my code I posted in the other thread. Albeit you have a similar question, the simple answer is:
Code:
$this->load->vars($data); //Make $data available to all views

As mentioned in the thread creating a $data property and using $this->data makes it available to any method/view to use.
#5

[eluser]InsiteFX[/eluser]
pickupman is correct!

You can read up on this in the CodeIgniter User Guide.

CodeIgniter Loader Class

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB