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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:28:30+00:00 2026-05-23T09:28:30+00:00

I have two controllers a and b . I would like to call a

  • 0

I have two controllers a and b.

I would like to call a method of controller a from a method of controller b.

Could anyone help explain how I can achieve this?

  • 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-23T09:28:31+00:00Added an answer on May 23, 2026 at 9:28 am

    This is not supported behavior of the MVC System. If you want to execute an action of another controller you just redirect the user to the page you want (i.e. the controller function that consumes the url).

    If you want common functionality, you should build a library to be used in the two different controllers.

    I can only assume you want to build up your site a bit modular. (I.e. re-use the output of one controller method in other controller methods.) There’s some plugins / extensions for CI that help you build like that. However, the simplest way is to use a library to build up common “controls” (i.e. load the model, render the view into a string). Then you can return that string and pass it along to the other controller’s view.

    You can load into a string by adding true at the end of the view call:

    $string_view = $this->load->view('someview', array('data'=>'stuff'), true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my users_controller I have two methods signup_process and login . I would like
I have two controllers which share most of their code (but must be, nonetheless,
I have a viewController (Planner) that loads two view controllers (InfoEditor and MonthlyPlan) when
I have two identical tables and need to copy rows from table to another.
I would like to keep model binding when doing ajax calls from my view.
I would like to have the keyboard already displaying when I show my view.
I have two different models that can show up in a category. In my
I have a view controller that has three scroll views as subviews. I would
I have a Reports controller and two types of users: companies and customers. Each
From my controller I am passing two instance variables @events = Event.all and @images

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.