• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Message: Undefined variable: css

#11
[eluser]jzmwebdevelopement[/eluser]
[quote author="CroNiX" date="1328651625"]Um, in your view (header.php), you are trying to echo $text, which you are not passing to the view. Change it to $css, which you ARE passing Smile[/quote]

My git is my new install and I tried a new value Smile

Code:
class Header extends CI_Controller {


public function index()
{
  $data = array();
  $data['text'] = "TEXT";
  $this->load->vars($data); // Lets all views see $data
  $this->load->view('admin/assets/header.php' , $data);
}
}

Code:
<!DOCTYPE html>
&lt;!--[if lt IE 7]> &lt;html lang="en-us" class="no-js lt-ie9 lt-ie8 lt-ie7"&gt; <![endif]--&gt;
&lt;!--[if IE 7]>    &lt;html lang="en-us" class="no-js lt-ie9 lt-ie8"&gt; <![endif]--&gt;
&lt;!--[if IE 8]>    &lt;html lang="en-us" class="no-js lt-ie9"&gt; <![endif]--&gt;
&lt;!--[if gt IE 8]>&lt;!--&gt; &lt;html lang="en-us" class="no-js"&gt; &lt;!--<![endif]--&gt;
&lt;head&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"&gt;
  &lt;title&gt;&lt;/title>
  &lt;meta name="viewport" content="width=device-width"&gt;
  &lt;?php echo $text; ?&gt;
&lt;/head&gt;
&lt;body&gt;

#12
[eluser]Aken[/eluser]
Your code on Github doesn't match the examples here. The code on there seems fine for the most part.

I can tell you that you can only add one level of subfolders to the controllers section - anything beyond that won't be found.

Maybe you're trying to do something through CodeIgniter and expecting a different result than how it is supposed to work.

#13
[eluser]jzmwebdevelopement[/eluser]
Aken,

I think you have hit the nail on the head,

In terms of a general ci file structure what would you recommend?


#14
[eluser]Aken[/eluser]
What you have is fine, just note that you cannot have controllers any deeper than one subfolder. Views can have many subfolders. Just keep that in mind when organizing your application.

If you have so many controllers that you require multiple sublevels for controllers, you might want to look into a module solution, or extending the way CI loads controllers to handle it.

I also don't really see why you have a controller specifically for generating the header of your page. I'd suggest searching around these forums for template systems and base controllers - both will have information on loading common resources such as headers and footers.

#15
[eluser]Aken[/eluser]
If your admin login page is where you are receiving the undefined variable error, it's because you are loading the view without passing any data to it. When you load a view, it does not inherit anything from a specific controller (like one with the same name). So your admin/assets/header controller is just sitting there doing nothing.

#16
[eluser]CroNiX[/eluser]
I don't understand this. He does have his header controller too deep (github version) (/application/controllers/admin/assets/header.php), but if the controller wasn't loading, wouldn't he NOT get the undefined variable error message and get an error about the controller not being found instead? After all, its that controller that is loading the view with the undefined variable.


#17
[eluser]jzmwebdevelopement[/eluser]
[quote author="CroNiX" date="1328652818"]I don't understand this. He does have his header controller too deep (github version) (/application/controllers/admin/assets/header.php), but if the controller wasn't loading, wouldn't he NOT get the undefined variable error message and get an error about the controller not being found instead? After all, its that controller that is loading the view with the undefined variable.

[/quote]

Correct, It is seeing the controller but its not passing the data

#18
[eluser]CroNiX[/eluser]
try just moving the header.php controller into /application/controllers/admin

#19
[eluser]jzmwebdevelopement[/eluser]
[quote author="CroNiX" date="1328653021"]try just moving the header.php controller into /application/controllers/admin[/quote]

Didn't work,

Is it something to do with my route? The reason I say this is because I can pass $data fine in the "main" welcome controller

#20
[eluser]Aken[/eluser]
It has nothing to do with your route. What URL are you viewing that is giving you the error?

[quote author="Aken" date="1328652789"]If your admin login page is where you are receiving the undefined variable error, it's because you are loading the view without passing any data to it. When you load a view, it does not inherit anything from a specific controller (like one with the same name). So your admin/assets/header controller is just sitting there doing nothing.[/quote]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.