I have a script that works, this one:
$output = $crud->render();
$data = array();
$data['title'] = 'Invoice details';
$output->data = $data;
$this->output($output); /* crud render and extra fields */
the thing is that this script is opening a function in the controler:
public function output($output = null) {
$this->load->view('template.php', $output);
}
and the template file as this: (and more)
<title><?php echo ucfirst($data['title']); ?></title>
works like a charm.
the template file is loading the header and footer and a bunch of css
when I want to open the invoice, I don't want to open the template, just invoice.php
so I created this:
public function invoice_print() {
$data = array();
$data['company'] = 'test';
$this->load->view('invoice.php', $data);
}
when I open the page I get a error:
A PHP Error was encountered Severity: Notice Message: Undefined variable: data Filename: views/invoice.php Line Number: 16
invoice.php line 16 = this:
<p class="bold"> <?php echo $data['company']; ?> </p>
how do I fix this?
regards,
Ralph
When you pass the variable to the view, you call the variable by the index:
$data['company'] = 'test';
$this->load->view('invoice.php', $data);
view:
<p class="bold"> <?php echo $company; ?> </p>
http://ellislab.com/codeigniter%20/user-guide/general/views.html