[quote name='visibility' timestamp='1327034738' post='310']
Glad to join here
I have problem when load my page, Css and Js not loaded.
please check source code and attach file
function users() {
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('users');
$crud->set_subject('Users');
$crud->required_fields('username');
$crud->columns('id_user','username','password','email','activated','usertype');
$output = $crud->render();
$this->load->view('administrator/includes/admin_header', array('output' => '' , 'js_files' => array() , 'css_files' => array()));
$this->load->view('administrator/admin_users', $output);
$this->load->view('administrator/includes/admin_footer');
}
What wrong?
please help, thank you
[/quote]
Probably you didn't add the js and css files to your header.
First of all ensure that you have this code to your admin_header.php:
<?php
foreach($css_files as $file): ?>
<link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
<script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
and then add it to your view so your code will be:
function users() {
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('users');
$crud->set_subject('Users');
$crud->required_fields('username');
$crud->columns('id_user','username','password','email','activated','usertype');
$output = $crud->render();
$this->load->view('administrator/includes/admin_header', $output); //<-- This line of code changed
$this->load->view('administrator/admin_users', $output);
$this->load->view('administrator/includes/admin_footer');
}
or if you don't need the output to your admin_header just have:
function users() {
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('users');
$crud->set_subject('Users');
$crud->required_fields('username');
$crud->columns('id_user','username','password','email','activated','usertype');
$output = $crud->render();
$header_output = (array)$output; //<-- This line of code added
unset($header_output['output']); //<-- This line of code added
$this->load->view('administrator/includes/admin_header', header_output); //<-- This line of code changed
$this->load->view('administrator/admin_users', $output);
$this->load->view('administrator/includes/admin_footer');
}
You can also use a template controller just to don't have repeating code in your project.