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 6779325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:19+00:00 2026-05-26T16:22:19+00:00

I’m building a site using CodeIgniter and up until now things have been going

  • 0

I’m building a site using CodeIgniter and up until now things have been going great. However, recently one of my controllers has been growing in size. I’d like to split the controller up into separate files within a sub-folder. Right now I have the following….

/controller/dashboard.php

Within that controller I have a function for the different sections. I check run a check to see if a usergroup has permissions to a section…etc. So, the URL might be something like this…

/dashboard/pages/add

I know I can setup a subfolder and have my URL be like the following….

/dashboard/staff/pages/add

But, I’d like to omit the ‘usergroup’ if at all possible. I’d like to do this by the following….

/controllers/dashboard/ -> If staff load staff.php, if user load user.php…etc.

I can’t do the following either….

$this->load->controller();

How would you suggest I setup a dashboard area? Each usergroup has different things they need to access. Putting everything in one document is getting too long, and separating them out means I have to put the usergroup in the URL….yucky.

Is it possible to run a check in routes.php?

if ($this->user_model->is_user()) {
  // load this controller
}

Hoping you guys will have some ideas for me!

Thanks,
Jacob

  • 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-26T16:22:20+00:00Added an answer on May 26, 2026 at 4:22 pm

    Well, a quick and dirty solution might using a redirect in a master controller…

    Create a “dashboard” controller inside controller/:

    class Dashboard extends CI_Controller {
    
    function index()
    {
      //make a check for the user that returns the usergroup:
      $user = $this->user_model->is_user();
      redirect('controller/'.$user.'/'.$user);
    }
    
    }
    

    wich basically whenever an admin goes to http://www.mysite.com/index.php/dashboard it just redirects to the corresponding user controller inside the folder controller. So if your check returns “staff”, it will redirect to controller/staff/staff.php and so on..

    As far as I know you can’t user custom expressions like that inside the router config.

    Another possible solution is using hooks. You might use a pre_controller hook

    pre_controller Called immediately prior to any of your controllers
    being called. All base classes, routing, and security checks have been
    done.

    Something like

    $hook['pre_controller'][] = array(
                                    'class'    => 'Select',
                                    'function' => 'get_usergroup',
                                    'filename' => 'Select.php',
                                    'filepath' => 'hooks');
    

    And you create a Select.php class file inside the application/hooks folder with a method get_usergroup() which grabs from the session or from a model the usergroup and do the needed redirect.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure

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.