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
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
April 11, 2011 3:24am
Subscribe [77]#16 / Apr 18, 2011 12:20am
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
#17 / Apr 18, 2011 2:07am
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
#18 / Apr 18, 2011 3:01am
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 :
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.
#19 / Apr 18, 2011 4:39am
The template controller works like this.
There is a main template and then when the controller finish it collect all the views and show it to the $output.
Ok now for your problem there are many things that is wrong.
1st I suggest to you to use all the crud and before or after the views for example :
function ketqua()
{
$data = 'just data';
$this->load->view('admin/home',array('my_data' => $data));
$this->load->view('....');
$crud = new grocery_CRUD();
$crud->set_table('kqmn');
$crud->render();
$this->load->view('....');
$this->load->view('....');
}The second thing is that in the template you MUST use the required code . There is no other way to add my css and javascripts into the template. So a solution for this (and you don’t have to delete your header and footer) is the below code to the template.php:
or a similar thing.
and to the includes header you MUST add the required code and the includes header will look something like this…
<head>
<title><?php echo $title; ?></title>
<meta ...../>
<meta ...../>
<meta ...../>
<meta charset="utf-8" />
<!-- 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; ?>
<!-- End of Required Code -->
Your javascripts here…
<link type="text/css" rel="stylesheet" href="your css here" />
<link type="text/css" rel="stylesheet" href="your css here" />
</head>But the header must have the required code and must be in the template. Its just the only way to add my javascripts and css to your custom css. Hope its not complicated.
#20 / Apr 18, 2011 5:19am
Thanks so much for your support!
I do like your instruction and this work!
Btw, have 2 litle issues :
1. Need to change to
$this->load->view('application/views/includes/header',array('css' => $css, 'js' => $js));in order this working at custom_cms/template.php. Don’t know why :down:
2. When i enable some function with IonAuth at include header :
Hello <a href="http://"><?php echo $this->ion_auth->get_user()->username; ?></a>this given error :
A Database Error Occurred
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group, groups.description AS group_description, meta.fullname, meta.cmnd, meta.p' at line 1
SELECT users.*, groups.name AS group, groups.description AS group_description, meta.fullname, meta.cmnd, meta.phone FROM (users) LEFT JOIN meta ON users.id = meta.user_id LEFT JOIN groups ON users.group_id = groups.id WHERE `users`.`id` = '1' LIMIT 1
Filename: D:\wamp\www\crud\system\database\DB_driver.php
Line Number: 330Notice that function work ok on other page not using CRUD.
I think have something conflict around here.
Thanks again for your help.
#21 / Apr 18, 2011 6:00am
Thanks so much for your support!
I do like your instruction and this work!
Btw, have 2 litle issues :
1. Need to change to
$this->load->view('application/views/includes/header',array('css' => $css, 'js' => $js));in order this working at custom_cms/template.php. Don’t know why :down:
2. When i enable some function with IonAuth at include header :Hello <a href="http://"><?php echo $this->ion_auth->get_user()->username; ?></a>this given error :
A Database Error Occurred Error Number: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group, groups.description AS group_description, meta.fullname, meta.cmnd, meta.p' at line 1 SELECT users.*, groups.name AS group, groups.description AS group_description, meta.fullname, meta.cmnd, meta.phone FROM (users) LEFT JOIN meta ON users.id = meta.user_id LEFT JOIN groups ON users.group_id = groups.id WHERE `users`.`id` = '1' LIMIT 1 Filename: D:\wamp\www\crud\system\database\DB_driver.php Line Number: 330Notice that function work ok on other page not using CRUD.
I think have something conflict around here.
Thanks again for your help.
It’s really really strange error.
For the first one (application/views/....) since it works that’s matters 😊 It was just a quick way to do it .
For the second : its really really strange. Try to do this :
<?php $ci = & get_instance(); ?>
Hello <a href="http://"><?php echo $ci->ion_auth->get_user()->username; ?></a>Perhaps this works.
#22 / Apr 18, 2011 6:14am
The error still there.
Look into error, i see that :
In the application/models/ion_auth_model.php have this line :
$this->db->select(array(
$this->tables['users'].'.*',
$this->tables['groups'].'.name AS '. $this->db->protect_identifiers('group'),
$this->tables['groups'].'.description AS '. $this->db->protect_identifiers('group_description')
));Don’t know why the function protect_identifiers not work like normal, so
$this->db->protect_identifiers('group')output : group and this is reserver word for mysql.
That’s very strange. I’ve also posted this issue on the IonAuth thread to see if Ben have
any suggestion.
Cheers.
#23 / Apr 18, 2011 6:44am
The error still there.
Look into error, i see that :
In the application/models/ion_auth_model.php have this line :
$this->db->select(array( $this->tables['users'].'.*', $this->tables['groups'].'.name AS '. $this->db->protect_identifiers('group'), $this->tables['groups'].'.description AS '. $this->db->protect_identifiers('group_description') ));Don’t know why the function protect_identifiers not work like normal, so
$this->db->protect_identifiers('group')output : group and this is reserver word for mysql.
That’s very strange. I’ve also posted this issue on the IonAuth thread to see if Ben have
any suggestion.
Cheers.
I think I found what the error is. Codeigniter active record automatically uses protect_identifiers so to your select is used two times! try to do this I think it will solve your problem.
$this->db->select(array(
$this->tables['users'].'.*',
$this->tables['groups'].'.name AS '. 'group',
$this->tables['groups'].'.description AS '. 'group_description'
));And is secure there is not problem in this.
#24 / Apr 18, 2011 8:57am
when i change to :
$this->tables['groups'].'.name AS `group`',This work like charm!
Thanks for your suggestion but im scare abit of change orgin IonAuth Code.
Btw, is anyway to deal with upload images and store filename at database?
Should i use callback_before_insert?
#25 / Apr 18, 2011 9:05am
when i change to :
$this->tables['groups'].'.name AS `group`',This work like charm!
Thanks for your suggestion but im scare abit of change orgin IonAuth Code.
Btw, is anyway to deal with upload images and store filename at database?
Should i use callback_before_insert?
Is on the future features. You can see many things that I will fix in the future by clicking to the link below :
Future features of grocery CRUD.
It’s a little bit complicated even to explain for how to do it. It’s not only the callback_before_add is the callback_field and you must change the form to multitype… etc etc. If you are a little bit patient I will inform you when I will added the uploading file. Thank you for you suggestions and I am glad to help you 😊
#26 / Apr 18, 2011 9:08am
Okie thank you so much!
Hope to hear any news about this powerful tool.
#27 / Apr 18, 2011 10:37pm
I create a new version of grocery CRUD v.1.0.1 for codeigniter 2.0.x . Actually this was a bug of codeigniter 2.0.2 (because I cannot include a config folder as module). But because we just need to do our job and keep going I create another way for the config files. The new version you will find it at google code hosting by clicking the below link
grocery CRUD version 1.0.1 for codeigniter 2.0.x
If you want just update your older files (from grocery CRUD v.1.0.0 to v.1.0.1) , just replace your old files with the new ones.
Hey… that’s cool! So I see that in order to fix it you moved all config files to application/config?
I spent some time myself trying to figure out what the problem was and I guess it is indeed a bug with 2.0.2 / Reactor!
If you edit system/core/Config.php around line 110/113 from
if ($found === FALSE)
{
continue;
}.. to…
if ($found === FALSE)
{
continue;
}
else
{
$found = FALSE;
}... it seems to solve it completely for v1.0.
I do not completely understand why those inner/outer loops are required in Config.php… but it just seems someone forgot to reset that $found var when exiting the inner loop… to prevent false positives from triggering the not found error. Maybe someone else can shed some light on this?
Have you submitted this error/request to Reactor codebase?
#28 / Apr 19, 2011 2:47am
Actually I totally knew that was a codeigniter error . To all my friends programmers I advise them NOT to use 2.0.2 . It has other bugs to do with security libraries. Though many people just download the latest stable(!!) version so they need a library just to work fine with their codeigniter.I didn’t do anything to report it, because at first I freak out why a so simple thing in my CRUD don’t play . That’s why I created the new version . Hope that codeigniter 2.0.3 will be more stable .
Actually as you find where the error was , you can report it as an error and recommend your code.It will be good to report it.
#29 / Apr 19, 2011 3:56am
It seems it has been reported already… so let’s hope a merge happens soon.
https://bitbucket.org/ellislab/codeigniter-reactor/issue/200/environment-changes-break-config-with
If you know of other unreported bugs please report them!
Thank you.
#30 / Apr 19, 2011 5:15pm
Thanks to report it.
I think the most bugs has been reported. So I wish to a new version. I use packages a lot and I want to include my libraries/models and configs to a separate folder.