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

  • SEARCH
  • Home
  • 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 5840859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:48:36+00:00 2026-05-22T11:48:36+00:00

using CodeIgniter normally one has to specify the controllers in the config/routes.php file. This

  • 0

using CodeIgniter normally one has to specify the controllers in the config/routes.php file.
This is not to handy, so I would like to be able to do something like this in a controller.

  1. get url parts and check if the first part is specified in an array
  2. if so, load the specified controller, if not, load default controller.

It basically mimics the behavior of the routes file, but there is no need to specify the wildcards before. I am using a base controller I extend with every controller, but I would like to have this controller just load (or include) the needed controller.

Does anyone have any idea how I can do this in a good way?

Thanks in advance.

// Edit

Okay, so here is my scenario.

I have cms and users can choose to include modules (e.g. a gallery).
I need to inlcude all the gallery php scripts without having to have “gallery” in the url.
I figured it would work if I use a “main controller” which loads another controller depending on the modules chosen. I realize this might not be the best way, so if there is a “clean” way to do it, please tell me.

As far as I know models are just for database stuff, so putting a whole gallery in there is not right either. The Plugin itself will of course be a library, but there is going to be some code to load the libs depending on the demands, get the database data, etc.

Thanks

  • 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-22T11:48:37+00:00Added an answer on May 22, 2026 at 11:48 am

    The way you’re doing this is incorrect. You never should take over the routing function to do this. What you need is to use some kind of module functionality to include the required methods and models; a module doesn’t require to have route-accessible methods, so it’s basically a “library” with a model and views.

    If I remember correctly there are several plugins that provide this, One was HMVC (google it).

    The ideal form would be to load the “Module” on demand from your controller, like you do with the core CodeIgniter Libraries; so lets say you’re inside the blog controller action and you want to include the comment module which is used on gallery and on images, you just include the module and call it’s methods to get the data which you can then pass to the view as needed; you can even render partials and store them into a variable to pass to your master controller.

    Hope this is enough to get you on the right track 🙂

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

Sidebar

Related Questions

I am thinking of using a PHP framework called CodeIgniter . One of the
I am using CodeIgniter, and in one of my models I would like to
Using codeigniter and oci8 for a project. $this->db->insert_id(); would would perfect for getting the
I am using CodeIgniter to pass some parameters to my PHP page through $_POST
I am developing a website using CodeIgniter and PHP. Some of my friends suggest
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
I've made a website using Flash in CodeIgniter. Normally when you link to a
i recently start using CodeIgniter as PHP MVC FrameWork , before CodeIgniter, i was
I am using Codeigniter framework for PHP. I was wondering if there is a
I am using codeigniter and below is my htaccess file. However, i want a

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.