CodeIgniter Forums
Cannot load views when running xampp - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Cannot load views when running xampp (/showthread.php?tid=26625)

Pages: 1 2


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]WavyDavy[/eluser]
I am trying to follow this tutorial here and I cannot load any views.
codeigniter-from-scratch-day-1/

I can echo no problems but I cant do anything else. Is my code ok or do I need to configure something in xampp?

This is the code for my controller site.php;
Code:
<?php
class Site extends Controller {

  function index() {
    $this->load->view('home');
  }

}
?>

And this is the code for my view home.php
Code:
<html>
<head>
<title>My Site</title>
</head>
<body>
    <h1>I have loaded my first view!</h1>
&lt;/body&gt;
&lt;/html&gt;
I am running XAMPP 1.7.3 on Windows XP Pro using version 1.7.2 of Codeigniter, site.php is in the controllers folder and home.php is in the views folder.


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]Cro_Crx[/eluser]
Your Site controller needs to have a constructor. Like this:

Code:
&lt;?php
class Site extends Controller
{

  function Site()
  {
    parent::Controller();
  }

  function index()
  {
    $this->load->view('home');
  }

}

It's good practice to leave out the ending ?&gt; tag on your code. http://ellislab.com/codeigniter/user-guide/general/styleguide.html#php_closing_tag


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]WavyDavy[/eluser]
Thanks for your reply.

I tried the code you gave but unfortunately it doesnt fix the problem.

Maybe there is something I need to config in the config folder or maybe this problem is a bug with 1.7.2?


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]flaky[/eluser]
make this little test
Code:
function index()
  {
    $test = $this->load->view('home', '', TRUE);
    echo $test;
  }

and put the result here


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]WavyDavy[/eluser]
I tried the test and got a 404 page


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]flaky[/eluser]
it looks like codeigniter can't find your view, either the file name is wrong or you placed it somewhere else.


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]WavyDavy[/eluser]
Its in my views folder, is that the right place for it?


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]flaky[/eluser]
if it is in
Code:
system\application\views\
then yes


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]WavyDavy[/eluser]
Here is a link to a screenshot of how my folders are setup.

I have tried moving the application folder back inside of the systems folder but that doesnt seem to fix it either.

I will try setting up a new Codeigniter directory from scratch.


Cannot load views when running xampp - El Forum - 01-19-2010

[eluser]flaky[/eluser]
Next time don't forget to mention the "small" details (that you've moved the application folder and other stuff)