Codeigniter load views within views : Sometimes we need to load views in another view, it is very simple to load view from another view using the $this->load->view(‘your_view’) method. Here in this article, we are going to explain to how you can load views within views.
Syntax : Codeigniter load views within views
We use the below syntax to load in controller, we can use the same syntax to load view in another view.
$this->load->view('your_view');
Example
Here is an example in which we have loaded another view in main view.
<title>My Home Page</title> <div id="left-sidebar" class="amp-wp-inline-e6b77a2e118003282dcbe625274e2ef8"> <?php $this-?>load->view('layouts/left_sidebar_view'); ?> </div> <div id="content" class="amp-wp-inline-93f654bc404ab9ff837dce17f8e9f736"> <h1>Welcome to the home page.</h1> <p>More Information Goes Here.......</p> </div> <div id="right-sidebar" class="amp-wp-inline-e6b77a2e118003282dcbe625274e2ef8"> <?php $this-?>load->view('layouts/right_sidebar_view'); ?> </div>
On the same way we can load multiple views in any view.