• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Views are not Loading

#1
[eluser]Greendots[/eluser]
My website has unexpectedly stopped loading my view files.

Code:
echo "1," ;
  $this->load->view("__header.php")  ;
  echo "2," ;
  $this->load->view("subfolder/my_view") ;
  echo "3," ;
  $this->load->view("__footer.php") ;
  echo "4" ;

will output:

Code:
1,2,3,4

The view files worked previously and generate valid xhtml. My admin pages work fine, but not any of the others. No changes have been made to the code.

Any idea how to troubleshoot this? My knowledge of CI is all over the place. I have invested a lot of time developing this website and learning CI as I went along, so I'm more than happy to get down and dirty with it.

-Thanks

#2
[eluser]pistolPete[/eluser]
Which CI Version are you using?
Did you overload the loader class using MY_Loader.php?
Are the views in subfolders?
Please provide some more code from your controller and views.

#3
[eluser]TheFuzzy0ne[/eluser]
When you say that no changes have been made to the code, do you mean the view files, or all of the code?

Did this happen after you uploaded your Web site?

Does your admin page use the same header?

Have you extended the Output class or Loader class at all?

Have you checked the actual output source for the page to see if any HTML is being output at all?

I would create a controller like this:
./system/application/controllers/test.php
Code:
<?php

class Test extends Controller {

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

    function index()
    {
        $this->load->helper('url');
        echo '<a href="' . base_url() . 'test/test_header">Test Header</a><br />';
        echo '<a href="' . base_url() . 'test/test_footer">Test Header</a>';
    }

    function test_header()
    {
        $this->load->view('__header');
    }
    
    function test_footer()
    {
        $this->load->view('__footer');
    }
}

Try navigating to:

yoursite.tld/test/test_header

and

yoursite.tld/test/test_footer

and see if you get any output with either of those.

#4
[eluser]Greendots[/eluser]
Nice idea. The same happens though, once I navigate there I get page load but no output. Strange that the error log is not reporting 'file not found' or whatever it does when a view file is not found.

#5
[eluser]pistolPete[/eluser]
Have you set
Code:
$config['log_threshold'] = 2; // or even higher

#6
[eluser]TheFuzzy0ne[/eluser]
Is your log directory writeable?

#7
[eluser]Greendots[/eluser]
Yes, no problems with the logs.
With log level set to 2 I get the usual debug messages about classes initialised and helpers loaded, but no errors.

edit: I have http://www.apicaday.co.uk/ hosted on the same server with almost identical layout and its not shown any of the same issues.

#8
[eluser]TheFuzzy0ne[/eluser]
I am trying to think of any differences between your admin views and your normal views.

What happens if you create a file like this:

./system/application/views/__header2.php
Code:
This is my header

and then try to load that view on it's own.

There's no HTML in there, and nothing to be parsed. If this works, then I'd start looking at the code for the views. Perhaps it's something to do with using short tags, and the server doesn't support them? If this is the case, you can enable short tag support from within the CodeIgniter configuration file. If it's already enabled, perhaps disabling it, and changing short tags to &lt;?php echo instead may work.

I know it looks like I'm taking a stab in the dark, but that's because I am.

#9
[eluser]Greendots[/eluser]
Thanks for the help folks, finally solved this one after a nightmare debugging session.

Seems my webhost rolled back to php 4, what a lot of nonsense. The CPanel showed php 5, but phpinfo() revealed the truth. Been more than happy with CI, so I'm glad it turned out not to be causing any issues Smile phew.

Will need to keep my eye on this bunch, have heard some right horror stories but until now its been smooth sailing.

#10
[eluser]TheFuzzy0ne[/eluser]
My hosting is with a UK company called Invisional.co.uk. They are really cheap but a fantastic host (other than the file upload limit of 2MB). Another alternative for the US is hostmonster.com. I've been hearing good things about them.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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