Can't access parent class' variables |
[eluser]Nuu[/eluser]
I was trying to stick some header data into MY_Controller class then access it from all the other pages. I keep getting the error 'Undefined Variable' when I try to access the variable ['mytitle'] in the view. This is my controller placed in Application/library/ folder. Code: <?php This is my test controller. Code: <?php Here's my test view. Code: <html> I have been looking at it for the last hour and just can't see why its wrong. I see a number of threads making reference to this method of coding e.g. How to extend controller class http://ellislab.com/forums/viewthread/71468/ Help ... :gulp:
[eluser]Armchair Samurai[/eluser]
In your view, try_calling $this->data['mytitle'], not $mytitle or adding $data['mytitle'] = $this->data['mytitle'] to your array in test() Also (I'm assuming this is a typo), you forgot to echo a value between the <title> tags.
[eluser]Nuu[/eluser]
I tried the view like this: Code: <html> I get the error "undefined index".
[eluser]Colin Williams[/eluser]
You need to pass the $this->data to your view, not $data. |
Welcome Guest, Not a member yet? Register Sign In |