⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

[Ask] Css and Js not loaded



visibility
  • profile picture
  • Member

Posted 20 January 2012 - 04:45 AM

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

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 20 January 2012 - 06:28 AM

[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.

visibility
  • profile picture
  • Member

Posted 20 January 2012 - 13:13 PM

it's work now. Thank you for help :)

elanouar
  • profile picture
  • Member

Posted 18 June 2013 - 17:56 PM

tks for your response


CyrolhTush
  • profile picture
  • Member

Posted 10 June 2015 - 07:06 AM

Thx big..


Juan Brics
  • profile picture
  • Member

Posted 09 January 2016 - 11:43 AM

Glad to Join Here

I am trying groceryCRUD the example, but the css doesnt working, only i can see columns but not colors in the rows... Someone know why?