Ok, I’ve found this amazing tool and trying to use in my development but I’m doing something wrong because don’t work. See what I’ve done until now:
1. Load needed libraries in __construct() (The other libraries needed are autoloaded).
public function __construct() {
parent::__construct();
$this->load->add_package_path(APPPATH . 'third_party/grocery_crud/');
$this->output->set_template('custom_cms');
$this->load->library('grocery_CRUD');
}
2. Write this piece of code in index():
public function index() {
if ($this->my_usession->logged_in) {
$this->grocery_crud->set_table('trasegados')
->set_subject('Trasegados')
->columns('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->required_fields('inicio_91', 'fin_91', 'total_91', 'inicio_95', 'fin_95', 'total_95', 'inicio_diesel', 'fin_diesel', 'total_diesel', 'id_estacion', 'usuario');
$this->grocery_crud->render();
$this->load->view('trasegados/form', $data);
} else {
redirect('user/login');
}
}
3. Echo $output at trasegados/form template:
<?php $this->load->view('layout_login_header'); ?>
<?php echo $output ?>
<?php $this->load->view('layout_login_footer'); ?>
4. Add the needed code at layout_login_header:
<?php foreach ($css as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
[removed]var base_url = '<?= base_url() ?>';[removed]
<?php foreach ($js as $file): ?>
[removed][removed]
<?php endforeach; ?>
But I got a lot of errors:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: css
Filename: views/layout_login_header.php
Line Number: 11
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/layout_login_header.php
Line Number: 11
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: js
Filename: views/layout_login_header.php
Line Number: 15
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: views/layout_login_header.php
Line Number: 15
See the entire output image here http://www.dropmocks.com/mUTRR Why t.his? What I’m doing wrong?
Cheers and thanks