I want to transfer data array from the controller to view the page but I already declared a variable ($data) that transfer to the view page.
How can I transfer 2 or more variable in the controller
Here's my code
Controller
public function manifest() {
$this->Auth->authCheck();
$data = $this->template();
$data_array = array(
'voyage_info' => $this->PortManifestModel->get_voyage()->result(),
);
// your code here
$this->load->view("port/client/manifest", $data);
}
view page
<a class="btn btn-primary primary-bg btn-lg col-md-4 m-2 btn-cus" href="#">
<?php foreach($voyage_info as $voyage) { ?>
<h3>Voyage <?=$voyage->voyage_number?></h3>
<small>Schedule</small>
<?php } ?>
</a>
I want to get voyage_info
or more data in view page, not just $data
. By the way, $data is for the template so I need it as well.
do like this
In controller
$data['template'] = $this->template();
$data['voyage_info'] = $this->PortManifestModel->get_voyage()->result();
$this->load->view("port/client/manifest", $data);
In View
$template # -> have your template data
$voyage_info # -> has your model data
There's a work around that I sometimes use, it's by creating an empty view file and then passing the data to that view.
Step 1 - Create a view empty.php
in views folder and don't put any contents in it.
Step 2 - call the view load before your normal view loads.
$this->load->view("empty", $data);
$this->load->view("port/client/manifest", $data);