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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:00:39+00:00 2026-06-18T23:00:39+00:00

I have done very much research on this topic but I cannot find how

  • 0

I have done very much research on this topic but I cannot find how i can do this. I am trying to add data to the $data parameter in a view that is being called from the controller of another view. However, any data i add to the subview via the subcontroller cannot be accessed by the subview. However, when I try to pass data to the subview via the client view, it works just fine. Most of the fixes on SO seem to reference just calling the $key in $data['key'] rather than $data so that doesn’t seem really relevant here…

I have two classes:

  • welcome.php – a page
  • welcomemenu.php – a set of controls intended to
    be loaded into welcome.php

Here is my Client Controller (the page that it’s on, welcome.php), which stores the return val from subview $welcomemenu in its own $data array…:

<?php

class Welcome extends CI_Controller {

    function __construct() {
        parent::__construct();      
    }

    function index() {
        //echo 'this is the Welcome index function';
        $data['clienttestdata'] = 'data from welcome.php!';
        $data['welcomemenu'] = $this->load->view('welcome/welcomemenu', $data, true);

        $this->load->helper('url');
        $this->load->view('templates/header');
        $this->load->view('pages/welcome', $data);
        $this->load->view('templates/footer');

    }
}

And here is the client view (“welcome_view.php” – seems simple enough. The $welcomemenu var is where I put the returns from my component class…):

    <section id="allWelcomeContent" class="mainBody">
        <header id="mainPageHdr" class=mainPageHdr>
            <!-- other stuff from my header -->
        </header>
        <!-- this is where i want to put the welcome menu... -->
        <section id="mainWelcomeContent" class="mainContent">
            <div>
                <?php echo $welcomemenu;?>
            </div>
        </section>
    </section>

And here is the Controller for my sub-component welcomemenu.php:

<?php

class Welcomemenu extends CI_Controller {

    public function __construct() {
        parent::__construct();
    }

    public function index() {
        $data['menu_items'] = array('About', 'Portfolio', 'Resume', 'Fun', 'Blog'); 
        $data['testdata'] = 'data from welcomemenu.php!';

        $this->load->view('welcome/welcomemenu', $data);
    }
}

And lastly: Here is the sub-view that is supposed to get data from its own controller, but cannot, even though it can take data from a calling client (i.e., the $clienttestdata shows up fine but $testdata doesn’t)!

<section>
<!-- TODO:  make this element repeatable so content can load from controller and/or model. -->
<div id="divMenuItems">
    <?php echo $clienttestdata;?>
    <?php echo $testdata;?>
</div>
</section>

Still i couldn’t find any proper solution. if anyone then please give me

  • 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-18T23:00:41+00:00Added an answer on June 18, 2026 at 11:00 pm

    When you’re including the welcomemenu partial in your Welcome/index method, you have to remember that the view does not go through its own controller. Instead, its contents are returned as a string and stored as a parameter. It gets all of its own parameters through the ones you send to it via $data:

    $data['welcomemenu'] = $this->load->view('welcome/welcomemenu', $data, true);
    

    This view will thus have access to everything in $data so far – nothing extra is added through the Welcomemenu controller. So, in the above case, it will have:

    array
    (
       'clienttestdata' => 'data from welcome.php!'
    )
    

    If you add the parameters you need to $data (as $data['testdata']), your sub-view will have what it needs.

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

Sidebar

Related Questions

I have done quite a bit of research on this but I'm still having
My primary language is PHP, but I have done some (not very much) programming
I have a very simple ajax request: $.get(url, data) .done(function () { }) .fail(function
So I have done some research, and have found you can create a boost::thread
I have done pretty much all my programming using C# and very much a
I'm trying to make a watermark appear inside a TexBox, I have done this
I am very new to the shell scripting world. I have done some research
I have recently done a very simple highlighting with jQuery and a highlight plugin.
I hope I am not missing something very simple here. I have done a
Have done some research and found some stuff that may be helpful. I would

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.