Welcome Guest, Not a member yet? Register   Sign In
My Navigation Site wont Load :(
#1

[eluser]crispinatari[/eluser]
Ive been trying for days and can't even manage to load a simple navigation site, i'm fine with normal php but using codeigniter takes a bit of adjusting to.

here is my home controller for my container page which should load the navigational structure for a home page.

Nothing loads, the load page just loops and times out. i have database as autoload but even when i set it to null nothing loads.

Home controller is:

Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

class Home extends Controller
{
function home()
    {
        // load controller parent
        parent::Controller();
        

      $this->load->helper('url');
      $this->load->helper('form');
      }

        
       function index()
       {
  
      $data['title'] = 'Employee Page';
      $data['header'] = $this->load->view('header', $data, true);
      $data['sidemenu'] = $this->load->view('sidemenu', $data, true);
         // load the sidemenu view
  
      $data['main'] = $this->load->view('mainnav', $data, true);  
      $data['footer'] = $this->load->view('footer', $data, true);
      
         // Load the Hello view with some DB stuff
  

      $this->load->view('container', $data);
        
    
    }

  

}
?>

container page is this:

Code:
<html>
<head>
<title><?php echo $title ?></title>
<link rel="stylesheet" type="text/css" href="employee.css" />
</head>


<body>
<table class="home" width="95%" cellpadding="1" cellspacing="1" align="center">
<tr valign="top">
<td valign="top" align="left" width="165" bgcolor="#CCCCCC">
&lt;?php echo $header ?&gt;</td>
<td valign="top" align="left">
&lt;?php echo $sidemenu ?&gt;</td>
<td valign="top" align="left">
&lt;?php echo $main ?&gt;</td>
</tr></table>
&lt;?php echo $footer ?&gt;


&lt;/body&gt;
&lt;/html&gt;

Routes page:
$route['default_controller'] = "Home";
$route['scaffolding_trigger'] = "";
Header Page
Code:
&lt;html&gt;
&lt;body&gt;
&lt;title&gt;&lt;?=$heading?&gt;&lt;/title&gt;
&lt;body&gt;
<h1>Welcome to my home page!</h1>
<p>Some text.</p>

&lt;/body&gt;
&lt;/html&gt;
#2

[eluser]TheFuzzy0ne[/eluser]
First of all, whilst this shouldn't matter too much, you should name your constructor identically to the class name, using the same case.

I think the problem in your case is that you are treating each view as a separate HTML file, but you need to treat some of them as snippets. Essentially, you're ending up with nested &lt;html&gt; tags which is not valid. So your header file should look like this:
Code:
<h1>Welcome to my home page!</h1>
<p>Some text.</p>

It would also benefit you to [url="http://validator.w3.org/"]validate your (X)HTML[/url].
#3

[eluser]TheFuzzy0ne[/eluser]
Hmmm, that shouldn't cause anything to loop or time out however. What I suspect may be happening is that you've enabled logging, but the ./system/logs is not writeable.
#4

[eluser]n0xie[/eluser]
Code:
// file: system/application/controller/home.php
class Home extends Controller
{
  function Home()
  {
    // load controller parent
    parent::Controller();
  }

  function index()
  {
    echo 'test';
  }
}

Code:
// file: system/application/config/routes.php
$route[‘default_controller’] = 'home';
Try if this works. The Class name should be identical to the constructor. Also the filename should be lowercase.
#5

[eluser]TheFuzzy0ne[/eluser]
Well spotted. The route should also be lowercase. I totally missed that.
#6

[eluser]crispinatari[/eluser]
test definately works so it does load, which means it could be the individual HTML for each view getting in the way, i'll keep you posted and thanks for the tips as well Smile
#7

[eluser]crispinatari[/eluser]
i'll change routs to lower case while i'm at it, everything is case sensitive.
#8

[eluser]n0xie[/eluser]
Just a small off topic remark. Using tables for general layout is usually not a good idea. Try to use DIV's and CSS to handle layout. Of course there could be valid reasons for doing it this way, but in my experience 99% of these reasons are more easily solved using standard CSS.
#9

[eluser]crispinatari[/eluser]
IT WORKEd! its so great to see it all appear on the page, some days i'm on a roll and other days if im not motivated then i lose track of the concept of what i'm actually trying to code, today was one of those days.
thanks again!

Ok i'll change table to div if that's the case. i've read that its more watertight but i've kept it for now just to see if i could set up the site properly




Theme © iAndrew 2016 - Forum software by © MyBB