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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:02:35+00:00 2026-06-07T21:02:35+00:00

I am trying to call a model from my controller, which in turn generates

  • 0

I am trying to call a model from my controller, which in turn generates data from a view, saves it as content and returns it to the controller, which then adds it to a template I have.

Whats happening is that $content = $this->load->view('left/profile', $c_data); is printing the data instead of saving it in variable $content

Here is my code:

Controller:

function index($page = '1-Welcome to')
{
        if (!$this->tank_auth->is_logged_in()) {
            //display non-login page
            redirect('/auth/login/');
        } else { 
    //user information
        $user['user_id'] = $this->tank_auth->get_user_id();
        $user['username'] = $this->tank_auth->get_username();
    //general page data
        $main['title'] = $this->page_model->make_title(ucfirst($page));
    //template data
        $template['head'] = $this->load->view('templates/head', $main, TRUE); 
    //get left content
        $c_data['make_profile'] = $this->left_model->make_profile($user);

    //combine into one variable
        $data['template'] = $template;
        $data['page'] = $page;
        $data['user'] = $user;
        $data['left'] = $c_data;
        print_r($data);
        $this->load->view('main_template', $data);
        }
}

Focus on $c_data['make_profile'] = $this->left_model->make_profile($user);

Here is make_profile

public function make_profile($user)
{
    $user_id = $user['user_id'];
    $query = $this->db->query(" SELECT location FROM user_profiles AS up 
                                INNER JOIN avatars AS a
                                ON up.avatar_id = a.id
                                WHERE user_id='$user_id'");
    $c_data['avatar_loc'] = $query->row_array();
    $content = $this->load->view('left/profile', $c_data);
    $content .= "hello";
    return $content;
}

And here is my profile view:

<div id="profile">
    <div id='avatar'><img src="<?php echo $avatar_loc['location'] ?>" alt="avatar_user"/></div>
    <div id="profile_pop"></div>
</div>

Any idea why it isn’t working? 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-06-07T21:02:36+00:00Added an answer on June 7, 2026 at 9:02 pm

    Return the data from the view as a string:

    $this->load->view('left/profile', $c_data, TRUE);
    

    Read here (bottom of the page).

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

Sidebar

Related Questions

I am trying to re-call core-data in UITable using model view. I am in
I'm trying to create programatically a custom view controller with subviews which center on
I am trying to build a program using model-view-controller. Specifically: I have a state
I'm trying to callback into my ViewResult Index() controller action from an ajax call
I am using latest codeigniter and trying to call stored procedure from my model.
I am trying to figure out how to pass the model object from controller
I have recently come across a problem trying to implement Model-View-Controller in Swing .
I am trying to call up a specific model of an entity in the
Trying to call a SAP SOAP Web Service from a generated sudzc app shows
Im trying to call a method that will add or subtract 1 from 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.