Welcome Guest, Not a member yet? Register   Sign In
CI 17.3 -> 2.0
#1

[eluser]Evollution[/eluser]
i upgraded my ci to 2.0 but know i cannot acces my blog page :

code

:
Code:
<?php

class Blog extends Controller {
    function Blog()
    {
    parent::Controller();
    $this->load->scaffolding('enteries');
    $this->load->helper('url');
    $this->load->helper('form');
    }


    function index()
    {
    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    $data['query'] = $this->db->get('blog');
  $this->load->view('blog_view', $data);
}
function comments()
    {
    $data['title'] = "My Comment Title";
    $data['heading'] = "My Comment Heading";
    $data['query'] = $this->db->get('enteries');
  $this->load->view('comment_view', $data);
    }
}

?>

i get a 404 error
#2

[eluser]bl00dshooter[/eluser]
First, you should extend CI_Controller, instead of Controller.

Second, you'd better use PHP5 constructors, like this:

Code:
<?php

class Blog extends Controller {
    function __construct()
    {
    parent::__construct();
    $this->load->helper('url');
    $this->load->helper('form');
    }


    function index()
    {
    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    $data['query'] = $this->db->get('blog');
  $this->load->view('blog_view', $data);
}
function comments()
    {
    $data['title'] = "My Comment Title";
    $data['heading'] = "My Comment Heading";
    $data['query'] = $this->db->get('enteries');
  $this->load->view('comment_view', $data);
    }
}

?>

Third of all, Scaffolding has been deprecated since CI 1.6, and removed as CI 2.0. You can't use it anymore.
#3

[eluser]Evollution[/eluser]
ok i changed code to
Code:
<?php

class Blog extends CI_Controller {
    function __construct()
    {
    parent::__construct();
    $this->load->helper('url');
    $this->load->helper('form');
    }


    function index()
    {
    $data['title'] = "My Blog Title";
    $data['heading'] = "My Blog Heading";
    $data['query'] = $this->db->get('blog');
  $this->load->view('blog_view', $data);
}
function comments()
    {
    $data['title'] = "My Comment Title";
    $data['heading'] = "My Comment Heading";
    $data['query'] = $this->db->get('enteries');
  $this->load->view('comment_view', $data);
    }
}

?>
and i get also 404

http://www.fifago.com/demo2/index.php/blog
#4

[eluser]Evollution[/eluser]
so anyone ?! i realy dont understand what is the problem here Sad
#5

[eluser]mdvaldosta[/eluser]
Looks like you've got it working to me? I don't see anything wrong with your latest controller code. The most important thing with CI 2.0 is extending CI_Controller and CI_Model and not using the plugins or scaffolding anymore. There are some other small things, taking a look over here is the most comprehensive look at the changes that I know of.
#6

[eluser]techgnome[/eluser]
I don't get a 404... I get "My Real Heading" in really large letters... so it seems OK to me.

-tg
#7

[eluser]Evollution[/eluser]
i changed the code Wink




Theme © iAndrew 2016 - Forum software by © MyBB