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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:33:06+00:00 2026-05-27T22:33:06+00:00

I have a main controller and I want to call child controllers from this

  • 0

I have a main controller and I want to call child controllers from this controller with HMVC. I setted a rule that routes parameter to a specific action that calls children controllers with “Request::factory” for the main controller but it didn’t work because of infinity loop. is there any way to do it?

I must use HMVC because main controller sends some information to children controller so I need a controlling layer.

It will be kind of a plugin for crud applications for a CMS.

The main controller: http://pastebin.com/nt2fhMEy

An example of child controller: http://pastebin.com/WqaHZaxf

Route: http://pastebin.com/6JGFf2i2 (I didn’t configure caction and cid yet.)

Extra Note: It will be kind of a crud module for my CMS. The main controller will load main template and some configs. Also the main controller includes some ORM functions and children controller must be able to use parent::functionname. The children controllers are in cruds/ directory and the cms creates them automatically.

  • 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-27T22:33:06+00:00Added an answer on May 27, 2026 at 10:33 pm

    You have a few mistakes in your idea of the controllers and HMVC.

    The best way to do so is to use object oriented controllers. By this I mean the “child controllers” need to extend the main controller.

    Let the main controllers extend Controller_Template and the child controllers extend the main controller.

    When you send requests to child controllers through routes you will not only have access to the parent properties, but your request will do the following:

    1. Before method of the main controller
    2. Before method of the child controller.
    3. Action of the child controller.
    4. After method of the child controller.
    5. After method of the parent controller.

    From what I get from your question you will not need HMVC at all. Actually it’s a very bad pattern for passing data. Keep in mind that when you perform an internal request through HMVC this is actually a completely new request. It will go through the routes and this list again. You will not have access to all of the previous request properties.

    Another tip: don’t put ORM functions in the main controller. Use the actual ORM models instead.

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

Sidebar

Related Questions

So I have a UIViewController (main application controller is a TabBarController). On this there
I have this in my controller: function foo() { // my code redirect(site_url('competitor/main'), 'refresh');
I have a controller in codeigniter called 'Main' with this function: public function index
I have a medium-complex Rails app. The main controller (the one that does what
I have a Python script that I want to use as a controller to
I have a Reports controller and various reports: http://localhost/reports/main/this_month http://localhost/reports/main/last_month http://localhost/reports/main/this_year I wanted http://localhost
I have main categories and sub categories. I want to be able to sort
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a main window (#1) on my webpage from which I open a
I have a main canvas 'blackboard' in a panel, this canvas has itself several

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.