Welcome Guest, Not a member yet? Register   Sign In
Documentation problem: Naming of Controllers & Models
#1

[eluser]Unknown[/eluser]
Hi folks,

I'm attempting to make my first CI-driven application by following the user guide, and I'm getting sightly confused by some of the examples given when it comes to naming controllers and models.

The controllers page (http://ellislab.com/codeigniter/user-gui...llers.html) instructs me to create a controller called 'Blog', which I did, and seemed fine until I got to the models topic (http://ellislab.com/codeigniter/user-gui...odels.html), where things start to become a little fuzzy:

It suggests that my new model file should be...
Quote:
Code:
class Model_name extends Model {...
Where Model_name is the name of your class. Class names must have the first letter capitalized with the rest of the name lowercase. Make sure your class extends the base Model class.

...which as I read it means that I should create a model called 'Blog'. Fine.. but I already created a class called 'Blog' for my controller. if you then keep reading you come across the following code:

Quote:
Code:
class Blog_controller extends Controller {

    function blog()
    {
        $this->load->model('Blog');

        $data['query'] = $this->Blog->get_last_ten_entries();

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

...which now suggests I am now to call my controller 'Blog_controller; and my model 'Blog' (will this affect the URL routing that I covered on the previous topic? Will my links now have to be /blog_controller/view/1 instead of /blog/view/1?). If you re-read the topic you realise the code at the top uses
Code:
class Blogmodel extends Model {

.. which suddenly attaches a 'model' suffix to the model, which hasn't been mentioned anywhere else and seems in contradiction to the previous example on the same page.

So are controllers 'Blog_controller' and models 'Blog' or are controllers 'Blog' and models 'Blogmodel' (or 'Blog_model'?). I'm sure its just a case of picking one and moving forwards at this point, but I'd quite like to know which way is 'correct', and the documentation seems really muddled as to exactly what I should be naming my classes. Hope you can see where the confusion is arising from. Smile


Messages In This Thread
Documentation problem: Naming of Controllers & Models - by El Forum - 02-06-2008, 05:21 PM
Documentation problem: Naming of Controllers & Models - by El Forum - 02-06-2008, 05:30 PM
Documentation problem: Naming of Controllers & Models - by El Forum - 02-06-2008, 05:44 PM
Documentation problem: Naming of Controllers & Models - by El Forum - 02-18-2008, 03:23 PM
Documentation problem: Naming of Controllers & Models - by El Forum - 10-26-2008, 11:49 PM
Documentation problem: Naming of Controllers & Models - by El Forum - 10-27-2008, 02:56 AM
Documentation problem: Naming of Controllers & Models - by El Forum - 10-27-2008, 08:25 AM



Theme © iAndrew 2016 - Forum software by © MyBB