Hello Every one i have samll Problem Here iam using codegniter and i have template that i use in all my views in some page i afound that i can use grocery crud as it will make it easer to show and it will give better look , as iam using to show table in one page i need to add the total of the amont in that table so creat model and store the result in varbile whene i show that var in the view page it show in the header of the page .here is my code
this the code for MY_controler
protected function render($template='main') {
//save the controller and action names in session
// i will add here the loginig function if its logeed it will work
// else it will send hime to loging page i will make it latter
// comments by samoual shingrai
if ($this->save_previous_url) {
$this->session->set_flashdata('previous_controller_name', $this->previous_controller_name);
$this->session->set_flashdata('previous_action_name', $this->previous_action_name);
}
else {
$this->session->set_flashdata('previous_controller_name', $this->controller_name);
$this->session->set_flashdata('previous_action_name', $this->action_name);
}
$view_path = $this->controller_name . '/' . $this->action_name . '.php'; //set the path off the view
if (file_exists(APPPATH . 'views/' . $view_path)) {
$this->data['content'] .= $this->load->view($view_path, $this->data, true); //load the view
}
$this->load->view("layouts/$template.tpl.php", $this->data); //load the template
}
and the secound is the code for the template
<div id="content">
<?php echo $content;?>
<?php
echo @$output;
?>
</div>
i show 2 value Content and output->for grocery crud
in the controler
function _example_output($page_set = null, $output = null) {
$this -> load -> view($page_set, $output,FALSE);
}
function index() {
$this -> _example_output((object) array('output' => '', 'js_files' => array(), 'css_files' => array(), 'data' => array()));
}
and then in my function
$crud -> where('client_id', $clientid);
$crud -> set_relation('client_id', 'client', 'name');
$crud -> set_relation('store_id', 'store', 'stname');
$crud -> unset_delete();
$crud -> unset_edit();
$crud->unset_add();
$output = $crud -> render();
$output->total=$this->client_model->client_account_total($_POST["T1"]);
// as you see i store the total
$page_set='clients/client_account';
$this -> _example_output($page_set, $output,true);
$this->render();
in the view page
<html>
<div id="total">
<label id="total">AVAILABLE BALANCE = </label>
<span><?php echo $total; ?></span>
</div>
</html>
so every thing is working fine but the result is not where it suppse to show in the $content or the $ourput Its showing in the header of the template .
any suggestion