⚠ 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

How to include output from grocery crud to my template



abdika

abdika
  • profile picture
  • Member

Posted 23 July 2012 - 07:26 AM

Hi, it's firstime i using grocery crud. I't very cool, but i have a problem.
I want to show output from grocery crud to my template
this is my Controler
[code] public function manageUser() { $crud = new grocery_CRUD();
$crud->set_table('users');
$crud->set_theme('flexigrid');
$crud->columns('username','email','tingkat','id_group');
$crud->display_as('id_group','kelompok'); $crud->display_as('tingkat','level'); $crud->fields('username','password','email','tingkat','id_group'); $crud->display_as('id_group','kelompok'); $crud->change_field_type('password', 'password');
//$crud->change_field_type('kelompok','enum');
$crud->set_relation('id_group','groups','kelompok' );
$output = $crud->render(); // $this->load->view('header.php');
$this->load->view('example',$output);

this is my template view[html]

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">

<head>
<title><?php echo $page_title;?></title>
<meta charset="utf-8" />
<meta name="description" content="Manage News Basket" />
<meta name="author" content="BeritaSatu" />

<style type="text/css">@import url("<?php echo base_url().'css/template.css'; ?>");</style>
<style type="text/css">@import url("<?php echo base_url().'css/admin.css'; ?>");</style>

</head>
<?php flush();?>
<body>
<div class="header-bar">
<?php $this->load->view('header', $username); ?>
</div>
<div class="container">
<div class="navigation">
<div class="navigation-inner">
<?php $this->load->view('admin_navigation'); ?>
</div>
</div>
<div id="main" class="main">
<?php $this->load->view('example'); ?>
</div>
<div class="footer-bar">
<?php $this->load->view('footer'); ?>
</div>
</div>

<script type="text/javascript" src="<?php echo base_url().'/library/jquery.js'; ?>"></script>
<script type="text/javascript" src="<?php echo base_url().'/library/tablesorter/jquery.tablesorter.js'; ?>"></script>
<script type="text/javascript" src="<?php echo base_url().'/library/myscript.js'; ?>"></script>
</body>

</html>[/html]

i want to show the output in main class, how to implement it?
[attachment=235:cats2.jpg]

arif rh

arif rh
  • profile picture
  • Member

Posted 15 September 2012 - 12:56 PM

add these lines to your template file :


<?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; ?>
<div>
<?php print_r($output); ?>
</div>


and then edit your controller like this :


public function manageUser() {
$crud = new grocery_CRUD();
$crud->set_table('users');
$crud->set_theme('flexigrid');
$crud->columns('username','email','tingkat','id_group');
$crud->display_as('id_group','kelompok'); $crud->display_as('tingkat','level'); $crud->fields('username','password','email','tingkat','id_group'); $crud->display_as('id_group','kelompok'); $crud->change_field_type('password', 'password');
$crud->set_relation('id_group','groups','kelompok' );
$output = $crud->render();
$this->load->view('template',$output); // load your template view
}