Welcome Guest, Not a member yet? Register   Sign In
blank screen on CI
#1

[eluser]davy_yg[/eluser]
Hello,

I wonder why I see blank screen on CI.

controllers/page.php

Code:
<?php
    class Page extends CI_Controller {
    public function index()
    {
    $this->load->view('index');
    }
    }
    ?>


views/index.php

Code:
<html>
    <link href= "<?php echo base_url(); ?>assets/css/style.css" rel="stylesheet" type="text/css" media="screen">
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed]
    $('#slideshow').cycle({
    fx: 'fade',
    speed: 900,
    timeout: 10000,
    pager: '#nav',
    pagerAnchorBuilder: function(idx, slide) {
    // return selector string for existing anchor
    return '#nav li:eq(' + idx + ') a';
    }
    });
    [removed]
    <?php include('includes/navigation.php'); ?>
    <body>
    <div id="slidesnav"><center><img src="&lt;?php echo base_url(); ?&gt;assets/images/slidesnav1.jpg"><img src="&lt;?php echo base_url(); ?&gt;assets/images/slidesnav2.jpg"><img src="&lt;?php echo base_url(); ?&gt;assets/images/slidesnav1.jpg"></center></div>
    <div id="demos">
    <div id="slideshow" class="pics">
    [removed]$('body').css('background-color', 'blue');[removed]
    [removed]$('body').css('background-color', 'red');[removed]
    [removed]$('body').css('background-image', 'url("../images/indonusa3.jpg")');[removed]
    </div>
    <ul id="nav">
    <li><a href="#"></a></li>
    <li><a href="#"></a></li>
    <li><a href="#"></a></li>
    </ul>
    </div>
    &lt;?php /*
    <img src="images/indonusa1.jpg" width="950" height="200" />
    <img src="images/indonusa2.jpg" width="950" height="200" />
    <img src="images/indonusa3.jpg" width="950" height="200" />
    */ ?&gt;
    <div id="products">
    <a href="connection.php"><img src="&lt;?php echo base_url(); ?&gt;assets/images/connection.jpg"></a>
    <a href="collaboration.php"><img src="&lt;?php echo base_url(); ?&gt;assets/images/collaboration.jpg"></a>
    <a href="solution.php"><img src="&lt;?php echo base_url(); ?&gt;assets/images/solution.jpg"></a>
    </div>
    &lt;/body&gt;
    &lt;?php include('includes/footer.php'); ?&gt;
    &lt;/html&gt;

routes.php

Code:
$route['default_controller'] = "page";
    $route['404_override'] = '';

Thanks.
#2

[eluser]LuckyFella73[/eluser]
What happens when you test like this:
Code:
&lt;?php
    class Page extends CI_Controller {
    public function index()
    {
   echo "Controller loaded";
    }
    }
/* End of file page.php */
/* Location: ./application/controllers/page.php */

Just to know if the view file is buggy

I never tested if it woks - you include view files in your view instead of loading
the CI way.
#3

[eluser]davy_yg[/eluser]

It works: http://localhost/IndonusaCI/index.php/page

Result:

Controller loaded


but it doesn't work if I replace:

echo "Controller loaded"; with $this->load->view('index');

http://localhost/IndonusaCI/index.php/page

Result:

Blank screen
#4

[eluser]CroNiX[/eluser]
try changing the view's filename to something other than "index.php".
#5

[eluser]davy_yg[/eluser]

Why not? I basically trying to make this link works:

http://localhost/IndonusaCI/

Later on will be www.indonusa.net.id

There shouldn't be any other name behind it.
#6

[eluser]LuckyFella73[/eluser]
You can have your links like you want - all he suggested is to rename the
VIEW file. You don't see the name of the view file in your url.
#7

[eluser]davy_yg[/eluser]
what should I name the controller since I will have to put the controller name in the url right?
#8

[eluser]LuckyFella73[/eluser]
You don't need to rename the controller. Just try this:
Code:
&lt;?php
class Page extends CI_Controller {
public function index()
{
  //echo "Controller loaded";
  $this->load->view('home'); // "home" instead of "index"
}
}
/* End of file page.php */
/* Location: ./application/controllers/page.php */

And rename your index.php file (the view file) to "home.php"

Your url in your browser is still the same that way.
#9

[eluser]davy_yg[/eluser]

Well, if the class name is page then I will have to type:

http://localhost/IndonusaCI/index.php/page to load it right?

Is it possible to load if I would like to type only localhost/IndonusaCI/ ?
#10

[eluser]LuckyFella73[/eluser]
Quote:Well, if the class name is page then I will have to type:

http://localhost/IndonusaCI/index.php/page to load it right?

Is it possible to load if I would like to type only localhost/IndonusaCI/ ?

Yes that's right. You can use .htaccess and call the page
http://localhost/IndonusaCI/page

And/ or edit your routes.php and set the controller "page" as the
"default_controller" instead of "home" then you have to type just the base url
http://localhost/IndonusaCI/ to get that page.




Theme © iAndrew 2016 - Forum software by © MyBB