EllisLab text mark
Advanced Search
1 of 23
1
   
v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD
Posted: 17 April 2011 05:38 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

I try to embed this at my current project but seem have many errors.

Seems that auto create the title and the data table appear immediately after this.

Can u provide me one example how to embed this like :

$this->load->view(‘template/header’);
$crud->render();
$this->load->view(‘template/footer’);


Thank so much.

 
Posted: 17 April 2011 05:45 PM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2010-09-20
2 posts

when i’m using wiredesignz codeigniter modular extensions i cnat do insert,delete and update in modules
is there any solution?

tanks

 
Posted: 17 April 2011 07:51 PM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
deadelvis - 16 April 2011 04:12 PM

Decided to try it out but FIY… works fine on 2.0.1 but it seems to be broken on 2.0.2 / Reactor. I am guessing due to changes in system/core/Config.php.

A PHP Error was encountered
Severity
Warning
Message
: include(application/third_party/config/grocery_crud.php[function.include]failed to open streamNo such file or directory
Filename
core/Config.php
Line Number
115

A PHP Error was encountered
Severity
Warning
Message
: include() [function.include]Failed opening 'application/third_party/config/grocery_crud.php' for inclusion (include_path='.:/Applications/MAMP/bin/php5.3/lib/php')
Filenamecore/Config.php
Line Number
115

An Error Was Encountered
Your application
/third_party/config/grocery_crud.php file does not appear to contain a valid configuration array. 

Haven’t yet figured out where to edit to fix.

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.

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 17 April 2011 07:58 PM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
tieungao - 17 April 2011 09:38 PM

I try to embed this at my current project but seem have many errors.

Seems that auto create the title and the data table appear immediately after this.

Can u provide me one example how to embed this like :

$this->load->view(‘template/header’);
$crud->render();
$this->load->view(‘template/footer’);


Thank so much.

Please be more specific. I cannot understand what the errors are. You can add your views to the top of your project or to the bottom of the project, as you show it

$this->load->view('template/header');

$crud = new grocery_CRUD();
$crud->columns(....)->.....
$crud->display_as(....
$crud->render();

$this->load->view('template/footer'); 

if you want to add a template you can see how you can do it by see the documentation at the below link

Installation for codeigniter

There I show how you can add your custom-template (I named it custom-cms) . If you have any more issues just ask.

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 12:20 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

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

 
Posted: 18 April 2011 02:07 AM   [ Ignore ]   [ # 16 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
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

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 03:01 AM   [ Ignore ]   [ # 17 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts
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.

 
Posted: 18 April 2011 04:39 AM   [ Ignore ]   [ # 18 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts

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:

<!DOCTYPE html>
<
html lang="en">
<?php 
     $this
->load->view('includes/header',array('css' => $css'js' => $js));
?>
<body>
    <
div>
        <
a href='<?=site_url('>Offices</a> | 
        <
a href='<?=site_url('>Employees</a> |
        <
a href='<?=site_url('>Customers</a> |
        <
a href='<?=site_url('>Orders</a> |
        <
a href='<?=site_url('>Products</a>

    </
div>
    <
div><?php 
                    
if(isset($modules->report)) 
                        foreach(
$modules->report as $module
                            echo 
$module;

    
?></div>
    <
div style='height:20px;'></div>  
    <
div>
        <!-- 
Required Code -->
        
<?php echo $output?>

        
<!-- End of Required Code -->
    </
div>
<?php 
     $this
->load->view('includes/footer');
?>
</body>
</
html

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.

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 05:19 AM   [ Ignore ]   [ # 19 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

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 downer


2. When i enable some function with IonAuth at include header :

Hello <a href=""><?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 groupgroups.description AS group_descriptionmeta.fullnamemeta.cmndmeta.phone FROM (usersLEFT 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
330 

Notice that function work ok on other page not using CRUD.


I think have something conflict around here.


Thanks again for your help.

 
Posted: 18 April 2011 06:00 AM   [ Ignore ]   [ # 20 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
tieungao - 18 April 2011 09:19 AM

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 downer


2. When i enable some function with IonAuth at include header :

Hello <a href=""><?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 groupgroups.description AS group_descriptionmeta.fullnamemeta.cmndmeta.phone FROM (usersLEFT 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
330 

Notice 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 grin 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=""><?php  echo $ci->ion_auth->get_user()->username;  ?></a

Perhaps this works.

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 06:14 AM   [ Ignore ]   [ # 21 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

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.

 
Posted: 18 April 2011 06:44 AM   [ Ignore ]   [ # 22 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
tieungao - 18 April 2011 10:14 AM

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.

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 08:57 AM   [ Ignore ]   [ # 23 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

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?

 
Posted: 18 April 2011 09:05 AM   [ Ignore ]   [ # 24 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
tieungao - 18 April 2011 12:57 PM

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 grin

 Signature 

- grocery CRUD - a codeigniter CRUD library - user guide and download
- Web and Development - personal Blog

 
Posted: 18 April 2011 09:08 AM   [ Ignore ]   [ # 25 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

Okie thank you so much!

Hope to hear any news about this powerful tool.

 
1 of 23
1