Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4579536
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:39:21+00:00 2026-05-21T20:39:21+00:00

So far, I create one controller for a site section with a method for

  • 0

So far, I create one controller for a site section with a method for each page – most are static pages, not requiring much logic or a model.

But where some of those pages are complex in functionality and need their own model, do I need to break them off into their own controllers? or is there a way to keep them in the one controller and load the model per method… probably the wrong thing to do

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:39:22+00:00Added an answer on May 21, 2026 at 8:39 pm

    Totally agree with jondavidjohn’s answer. I suggest just doing what works for you for now, and don’t worry too much about overhead or doing the “correct” thing. You’ll shortly realize what you need to do and how to be organized, and as far as overhead – Codeigniter is pretty lean, don’t worry about optimization at this point – just get everything to work the way you want.

    Take your first Codeigniter project and make it the best you can, but just consider it a throw-away app. Each time you work with it you’ll learn more about how to use it, and especially if you keep reading and asking questions.

    To answer your literal question: No, there’s nothing wrong with loading the model per method. In fact, it can be “better” than loading in the __construct of your Controller, because it ensures you only load exactly what you need. So don’t worry about it.

    So far, I create one controller for a site section with a method for each page – most are static pages

    There’s nothing wrong with this, but to make things easier, you can use the same method for each of your static pages, and keep your urls the same. Something like this:

    class Pages extends CI_Controller {
    
        public function __construct()
        {
            parent::__construct();
        }
    
        function index($page)
        {
            $this->load->view("pages/$page");
        }
    
    }
    
    // config/routes.php
    $route['page/(:any)'] = 'pages/index/$1';
    

    This would map the url /page/my_first_page to the Page controller and call index() with the argument my_first_page. Then you can use this for all your static pages without dynamic data. You can take this a lot further, but it’s an example of one option you can choose to avoid writing a new method for every static page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As far as I know (not much I'll admit), the currently popular programming paradigms
As far as i know it is not possible to do the following in
As far as I know, foreign keys (FK) are used to aid the programmer
So far I have encountered adjacency list, nested sets and nested intervals as models
As far as I know, Flash has to pass info off to another external
As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
As far as variable naming conventions go, should iterators be named i or something
As far as I can tell, this is isn't possible, so I'm really just
As far as tools go, I am aware of Haxe , MTASC , and
As far as I've gathered (read: measured), building the configuration and the sessionfactory by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.