felix_ - 07 June 2011 06:41 PM
my problem is, that im using my own “template engine” .. not really an engine just a view which loads the header, adds the meta data etc
when i call render from the crud object all the content from the template is written BEFORE anything else is written to the html document
then all my stuff is coming and (why ever) the flexitable is written to the correct position in the document
i red the documentation on your website but i dont really get what i do wrong
maybe you can help me live via twitter, jabber, icq or whatever
greetz
Hello felix_ , I would like to help you via twitter , jabber etc but I really don’t have enough time. I am really busy the last days so I found a solution for you , hope its easy:
1st step comment your template. As you use your own “template” controller you will not need mine. So go to the contructor and comment the line
//$this->output->set_template('custom_cms');
(or whatever)
2nd Stepadd this 3 functions to your basic controller (I test this functions that works)
protected function _get_all_javascripts()
{
return $this->load->get_js_files();
}
protected function _get_all_css()
{
return $this->load->get_css_files();
}
protected function _get_all_views()
{
$output = $this->output->get_output();
//As you get the output you don't need anymore the output to view it automatically
$this->output->final_output = '';
return $output;
}
wherever you like.
3rd Step you can “take” what grocery crud do automatically to the template controller at your function . So for example at my employees_management function you will have:
function employees_management()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','public/uploads/files');
$crud->render();
$js_array = $this->_get_all_javascripts();
$css_array = $this->_get_all_css();
$views = $this->_get_all_views();
$data = array('js_array' => $js_array , 'css_array' => $css_array, 'grocery_crud_as_string' => $views);
$this->load->view('my_custom_template',array('crud_data' => $data));
}
and the full controller (I just copied to understand exactly what I mean)
class Examples extends CI_Controller {
function __construct()
{
parent::__construct();
/* Standard Libraries */
$this->load->database();
$this->load->helper('url');
/* ------------------ */
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');
//$this->output->set_template('custom_cms');
$this->load->library('grocery_CRUD');
}
function index()
{
}
function employees_management()
{
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('employees');
$crud->set_relation('officeCode','offices','city');
$crud->display_as('officeCode','Office City');
$crud->set_subject('Employee');
$crud->required_fields('lastName');
$crud->set_field_upload('file_url','public/uploads/files');
$crud->render();
$js_array = $this->_get_all_javascripts();
$css_array = $this->_get_all_css();
$views = $this->_get_all_views();
$data = array('js_array' => $js_array , 'css_array' => $css_array, 'grocery_crud_as_string' => $views);
$this->load->view('my_custom_template',array('crud_data' => $data));
}
protected function _get_all_javascripts()
{
return $this->load->get_js_files();
}
protected function _get_all_css()
{
return $this->load->get_css_files();
}
protected function _get_all_views()
{
$output = $this->output->get_output();
$this->output->final_output = '';//As you get the output you don't need anymore the output to view it automatically
return $output;
}
...........etc
}
hope that helps