CodeIgniter Forums
All controllers but default return Untitled Document - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: All controllers but default return Untitled Document (/showthread.php?tid=35021)

Pages: 1 2 3


All controllers but default return Untitled Document - El Forum - 10-16-2010

[eluser]jakemac53[/eluser]
http://www.jacobmacdonald.com

For some reason the url routing isn't working at all, no matter what i put in the url i get an untitled document thats blank returned. The default controller does load however though on the homepage (what you see on homepage should be the same as http://www.jacobmacdonald.com/index.php/game, which just gives an untitled doc ). Any ideas?

I have used CI in the past many times with no issue....any config option i could have missed that would cause this?


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]InsiteFX[/eluser]
The untitled document is coming from the head title tag!

The page is blank because there is nothing inbetween the body tags.

InsiteFX


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]mi6crazyheart[/eluser]
Don't u've any controller by name "game"... ?


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]jakemac53[/eluser]
[quote author="InsiteFX" date="1287336366"]The untitled document is coming from the head title tag!

The page is blank because there is nothing inbetween the body tags.

InsiteFX[/quote]

I don't think you understood, i know its serving up a blank page already, but it SHOULD have stuff. Its not loading views or doing anything and for some reason its serving up that blank page.

[quote author="mi6crazyheart" date="1287341051"]Don't u've any controller by name "game"... ?[/quote]

Yes there is a controller called "game" which is set as the default controller. It works on the homepage because its the default, but if i go to http://www.jacobmacdonald.com/index.php/game it doesn't.

Below is the code for the controller currently:

<?php

class Game extends Controller {

function Game()
{
parent::Controller();
$this->load->model('User_model', 'User');
}

function index()
{

if(!$this->User->logged_in()){
$login = $this->User->login();
}else{
if( $this->input->post('logout') == "Yes"){
$this->User->logout();
$login = false;
}else{
$login = true;
}
}
switch($login){
case -1:
$error = "incorrect username or password";
$login = false;
break;
case -2:
$error= "username already exists";
$login = false;
break;
default:
$error = "";
break;
}

$this->load->view('header_view');
$this->load->view('login_view', array('error'=>$error, 'logged_in'=>$login, 'username'=>$this->User->logged_in()));
$this->load->view('game_view');
$this->load->view('footer_view');
}

}


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]InsiteFX[/eluser]
Code:
$this->load->view(‘header_view’);
      $this->load->view(‘login_view’, array(‘error’=>$error, ‘logged_in’=>$login, ‘username’=>$this->User->logged_in()));
      $this->load->view(‘game_view’);
      $this->load->view(‘footer_view’);

// To this, this is how to pass the parameters to your view:
$data[title] = 'Your Title';
$data[error] = $error;
$data[logged_in] = $login;
$data[user_name] = $this->User->logged_in();

$this->load->vars($data);

$this->load->view(‘header_view’);
$this->load->view(‘login_view’);
$this->load->view(‘game_view’);
$this->load->view(‘footer_view’);

InsiteFX


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]jakemac53[/eluser]
I only need the data in the game view is why Im doing it that way.....was intentional. No point in building the array beforehand just to pass it there other than its a bit cleaner but this is just something I will be updating so when i start getting line wrap i will do that....either way this has nothing to do with the error i am getting.....


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]mi6crazyheart[/eluser]
Code:
function Game()
  {
      parent::Controller();
      $this->load->model(‘User_model’, ‘User’);
  }

In u'r controller function "game" there is no VIEW. Without any view how u'r poor controller function game will able to show u any view... Undecided


All controllers but default return Untitled Document - El Forum - 10-17-2010

[eluser]jakemac53[/eluser]
[quote author="mi6crazyheart" date="1287398885"]
Code:
function Game()
  {
      parent::Controller();
      $this->load->model(‘User_model’, ‘User’);
  }

In u'r controller function "game" there is no VIEW. Without any view how u'r poor controller function game will able to show u any view... Undecided[/quote]


???? That's just the constructor for the controller... if you look right below that I have the index() function which does load views.....

I think the main thing you guys aren't getting is that this controller DOES work, just only when its being loaded on the homepage as the default controller. It DOES call views, and they ARE displayed. However, you can't access the controller directly or any other controllers for that matter by going to the full url path for them. This is the core issue....


All controllers but default return Untitled Document - El Forum - 10-18-2010

[eluser]tonanbarbarian[/eluser]
your issue is routing
what wewbserver are you using?
if apache do you have a htaccess file?
what are your config options?


All controllers but default return Untitled Document - El Forum - 10-18-2010

[eluser]jakemac53[/eluser]
I am using a linux setup on hostmonster, i am currently using no htaccess file just because i thought that might be the issue originally, but i could put the old one back. When i did have one it was the one codeigniter gives you in tutorials just to remove the index.php from the url.

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]