Welcome Guest, Not a member yet? Register   Sign In
Controllers not loading views
#1

[eluser]ssharp[/eluser]
I have three controllers in my app. Two of them will not load views and the other will. It's not an issue with the actual view files, because the controller that does work will load the views associated with the other two controllers. The two controllers that don't work will not load any view at all.

Note that everything worked fine until I put the files on a new server. I think the config is okay but I'm not sure why CI is behaving this way.

The the controllers that aren't working produce 404 Pages.

Any ideas? This is driving me crazy!
#2

[eluser]new developer[/eluser]
Did you check the .htaccess file..i am new as well
#3

[eluser]hugle[/eluser]
[quote author="ssharp" date="1226533477"]I have three controllers in my app. Two of them will not load views and the other will. It's not an issue with the actual view files, because the controller that does work will load the views associated with the other two controllers. The two controllers that don't work will not load any view at all.

Note that everything worked fine until I put the files on a new server. I think the config is okay but I'm not sure why CI is behaving this way.

The the controllers that aren't working produce 404 Pages.

Any ideas? This is driving me crazy![/quote]

give the path name, controled file name (.php) and the source of the controleer witch is not working.

also the view file would be welcome.
#4

[eluser]ssharp[/eluser]
Here is the .htaccess

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|html|psd|custom|cgi-bin|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

The controllers names are: equipment, cart, and admin. Admin works, the other two don't. The views are all in subfolders called equipmnet/, cart/ and admin/. As a note, I tried loading views from cart/ in the admin controller and it worked. I also tried loading admin/ views in the controllers that weren't loading views and this didn't work.
#5

[eluser]ssharp[/eluser]
Here is a controller that works.

Code:
class Admin extends Controller {
    
    function Admin() {
        parent::Controller();
        $this->load->model('EquipmentModel');
    }
    
    function Index() {
        $this->load->view("admin/index");
    }
        
        function LoadOtherView() {
                $this->load->view("cart/index");
        }

}

www.mysite.com/admin/index works
www.mysite.com/admin/loadotherview works

Here is a controller that doesn't work:

Code:
class Cart extends Controller {

    function Cart() {
        parent::Controller();
        $this->load->model("CartModel");
    }
    
        function Test() {
          echo "Hello!";
        }
    

    function View() {
        $totals = $this->CartModel->GetItemsTotals();
        $items = $this->session->userdata['items'];
        $counties = $this->CartModel->GetCounties();
        $viewData = array("items" => $items, "itemTotals" => $totals, "counties" => $counties);
        $this->load->view("cart/view", $viewData);
    }
}

www.mysite.com/cart/view doesn't work
www.mysite.com/cart/test does work

The cart/view function works fine. If I did a print_r($viewData) and die(); right before the $this->load->view, it would output the $viewData just fine. It's failing when it loads the view.
#6

[eluser]Colin Williams[/eluser]
view() is a reserved method if you are running PHP 4. Might be causing issues..
#7

[eluser]orotone[/eluser]
Are you developing on windows and uploading to a Linux/Unix server? If so, case on your file names matters in the Linux/Unix world and doesn't in the windows world.
OT
#8

[eluser]ssharp[/eluser]
Thanks for the help, they were all PHP4 issues. Didn't even think of that as I haven't used a server running PHP4 in several years. I just had to change some names around...I was developing on OSX, so the file names weren't the problem just some restricted words.




Theme © iAndrew 2016 - Forum software by © MyBB