web-johnny - 18 April 2011 06:07 AM
tieungao - 18 April 2011 04:20 AM
Let’s say we have one example below :
function offices()
{
$user = $this->ion_auth->get_user()->username;
$this->grocery_crud->render();
}
How i can display var $user at your custom_cms template?
Thanks
You can simply do
function offices()
{
$user = $this->ion_auth->get_user()->username;
$this->load->view('login_as',array('username' => $user));
$this->grocery_crud->render();
}
Or whatever view you like (before crud or after). And it will load in the $output as I say to the documentation. Its pretty simple.
I have also sections on the template. But I still don’t want to make it more complicated for you. If though you really need to do it with sections , for example : section user , section menu , section footer etc. Just ask it for.
Hope this helps
Thanks so much for your fast support!
In fact i already have a project with header, footer and templates.
Now i want to embed your CRUD to this.
I’ve tried to do like that :
in controllers/admin.php :
function __construct()
{
parent::__construct();
$this->load->library('ion_auth');
$this->load->helper(array('form','url'));
$this->load->library('session');
$this->load->library('form_validation');
if (!$this->ion_auth->logged_in()) redirect("auth/login");
$this->load->database();
$this->db->query('SET names utf8');
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');
$this->load->library('grocery_CRUD');
$this->output->set_template('custom_cms');
if (!$this->ion_auth->is_admin()) redirect(base_url());
}
function ketqua()
{
$crud = new grocery_CRUD();
$crud->set_table('kqmn');
$this->load->view('includes/header',$this->data);
$this->load->view('admin/home',$this->data);
$this->load->view('includes/footer',$this->data);
$crud->render();
}
and change your template.php at custom_cms to :
<div><?php
if(isset($modules->report))
foreach($modules->report as $module)
echo $module;
?></div>
<div style='height:20px;'></div>
<div>
<?php echo $output; ?>
</div>
at my old includes/header.php i add your required code :
<?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; ?>
and at admin/home.php i add required code :
<div class="for_CURD">
<?php echo $output; ?>
<div>
but seems that this CRUD output not appear directly at div class=“for_CURD”
Thanks so much for helping me.