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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:07:32+00:00 2026-06-15T09:07:32+00:00

I am developing a CRM for our agency in Codeigniter and I have a

  • 0

I am developing a CRM for our agency in Codeigniter and I have a question that I can’t seem to find a solid answer on. If I have a task that I do on the majority of methods in a controller, is there any way to define that action only once? For instance…

Every view call gets passed the $data variable, like so…

$this->load->view('templates/template.php', $data);

So if I am doing something like getting the admins information in every function of the controller, how can i tell it to do that action ONE time and pass it to all my functions.

Like this…

$data['admin'] = $this->Crm_model->get_admin();

I’ve tried putting that ^ in the constructor and it doesn’t work. Any ideas?

  • 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-06-15T09:07:33+00:00Added an answer on June 15, 2026 at 9:07 am

    If you do:

    $data['admin'] = $this->Crm_model->get_admin();
    

    in the constructor, $data‘s scope is limited to the constructor. You need to create it as a class property so it is scoped to the entire class. Do this instead

    $this->data['admin'] = $this->Crm_model->get_admin();
    

    in the constructor, and then in other methods, you can access the array by doing $this->data

    Here’s an example:

    class Foobar extends CI_Controller {
    
        public function __construct() {
            $this->data['foo'] = "bar";
        }
    
        public function index() {
            // use the class property data here to add more info to it
            $this->data['hello'] = "world";
    
            // now pass this to the view
            $this->load->view('myView', $this->data);
            // myView will receive both $foo and $hello
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing a c# application that imports address-data into a CRM-system. The CSV-file
Developing for Android 2.3, I have a question regarding layouts. I use a vertival
Developing a network application, I have a Connection class that manages sending and receiving
We are developing a large applications which are related to business. You can find
we are developing a CRM app which holds customer meeting info. Users have requested
I'm developing against MS CRM 2011. And I find out there are a lot
I'm currently on the task of developing a Sales/CRM application on MVC3. Since lots
Developing an app that people pay a monthly subscription to use. They can pay
Our Company is developing a CRM and we came now to the point where
Developing a project of mine I realize I have a need for some level

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.