Welcome Guest, Not a member yet? Register   Sign In
How to encapsulate view-components?
#3

Maybe this will help.
Put this code in both views that should display the table:
PHP Code:
<div class="tableFrameā€œ>
<?php 
$this->load->view('embedded_viewfile');?>
</div> 
Where 'embedded_viewfile' is the name of the view that you want to embed.

You probably need to pass variables (the records) to the embedded view.
If you do that from the controller, you can make these variables global.
Before you load the 'container' views, do this:
PHP Code:
$data['records'] = ... // an array with records from a database table, collected by a query (e.g. in a model)
$this->load->vars($data['records']); 

In the embedded view, the $records array is available for displaying the data.
Reply


Messages In This Thread
How to encapsulate view-components? - by jellix - 08-30-2019, 08:47 AM
RE: How to encapsulate view-components? - by Wouter60 - 09-01-2019, 10:22 AM



Theme © iAndrew 2016 - Forum software by © MyBB