How do you put two different function outputs from the same controller into the same view(page)? For example, I have a function going to the "article" div, and another function that I am trying to use within the "aside" div. (using HTML 5 nomenclature here)
I have went as far as using the actual db query in the (view)aside div and it still only displays the 1st article function.
I have changed the $data('result') variable to separate variables and that makes no difference.
I am showing a todo list of jobs I have to do in the article div, then showing the titles of the completed todo's in the aside div.
I suppose I am making a mess of this explanation. Would you use a function from a different controller?
This is the first code in the controller
function index()
{
$this->load->model('work_m');
$data = array();
$config['base_url'] = base_url() . 'index.php/work/index/';
$config['total_rows'] = $this->db->count_all('work');
$config['per_page'] = '10';
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);
$data['result'] = $this->work_m->get_records($config['per_page'], $this->uri->
segment(3));
$tmpl = array('table_open' =>
'<table border="0" cellpadding="0" cellspacing="0">', 'heading_row_start' =>
'<tr class="heading">', 'heading_row_end' => '</tr>', 'heading_cell_start' =>
'<th>', 'heading_cell_end' => '</th>', 'row_start' => '<tr>', 'row_end' =>
'</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' =>
'<tr class="alt">', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>', 'table_close' => '</table>');
$this->table->set_template($tmpl);
$this->table->set_caption("Work Items");
//-- Header Row
$this->table->set_heading('ID', 'Date', 'Title', 'Done', 'Item');
//-- Content Rows
$data['title'] = 'Page Display';
$this->load->view('work_links', $data);
Note it points to work_links, a view
the next function is this
function done()
{
$data = array();
if ($query = $this->work_m->dead_work()) {
$data['dead'] = $query;
}
$tmpl = array('table_open' =>
'<table border="0" cellpadding="0" cellspacing="0">', 'heading_row_start' =>
'<tr class="heading">', 'heading_row_end' => '</tr>', 'heading_cell_start' =>
'<th>', 'heading_cell_end' => '</th>', 'row_start' => '<tr>', 'row_end' =>
'</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' =>
'<tr class="alt">', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>',
'cell_alt_end' => '</td>', 'table_close' => '</table>');
$this->table->set_template($tmpl);
$this->load->view('work_links', $data);
}
The models behind them are basic calls to the database
Now this code in the view goes with the first function above(in the article div) and works perfectly
foreach($result as $row)
{
$this->table->add_row(
anchor("work/fill_form/$row->id", $row->id),
$row->date,
$row->title,
$row->compl,
$this->typography->auto_typography($row->item)
);
}
$table = $this->table->generate();
echo $table;
this is the second code to go into the aside div(and goes with the second functiin above)
if (isset($dead)){
foreach($dead as $row)
{
$this->table->add_row(
$row->id,
$row->title,
$row->finish
);
}
}
$this->table->set_heading('ID', 'Title');
$table = $this->table->generate();
echo $table;
The last code only picks up the data from the first function no matter what i do.