Thomas John Thomas John - 5 months ago 26x
PHP Question

codeigniter : pass data to a view included in a view

I have a controller and including two views from one function as below


The view file
including a php menu file as follows

<? $this->load->view('includes/top_menu'); ?>

My question is, how can I pass data that is fetched from the controller to this included

Thank you guys


Inside your controller, have

$data['nestedView']['otherData'] = 'testing';

before your view includes.

When you call


the view_destinations file is going to have


Which you can at that point, pass into the nested view file.

<? $this->load->view('includes/top_menu', $nestedView); ?>

And inside your top_menu file you should have $otherData containing 'testing'.