EllisLab text mark
Advanced Search
     
groceryCRUD problem with success message
Posted: 07 June 2011 01:14 PM
Joined: 2011-01-19
39 posts

Hey,
i hav a problem with groceryCRUD…
after added or deleting an entry in my database i got the following output.
i think something is wrong there but i dont really what goes wrong :/
the overview table itself looks just fine

 
Posted: 07 June 2011 01:21 PM   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
felix_ - 07 June 2011 05:14 PM

Hey,
i hav a problem with groceryCRUD…
after added or deleting an entry in my database i got the following output.
i think something is wrong there but i dont really what goes wrong :/
the overview table itself looks just fine

This is a javascript error. You have a javascript error so the form is just send normally. This is the ajax response from the add form . Check your javascripts if you have any confict and try again.

 Signature 

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

 
Posted: 07 June 2011 01:38 PM   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-01-19
39 posts

ah ok… the error comes from jquery 1.5.1 which ships with grocery crud…

Uncaught TypeError: Object [object Object] has no method ‘numeric’

i tried to integrate the template output in a normal view in my application but all the output for loading the jquery stuff is in front of my

<link type="text/css" rel="stylesheet" href="http://localhost/chesus/public/grocery_crud/themes/flexigrid/css/flexigrid.css" />
[removed]var base_url 'http://localhost/chesus/';[removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
<style type='text/css'>
body
{
    font
-familyArial;
    
font-size14px;
}
a {
    color
blue;
    
text-decorationnone;
    
font-size14px;
}
a
:hover
{
    text
-decorationunderline;
}
</style>
    <
div></div>
    <
div style='height:20px;'></div>  
    <
div>
        <!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<!-- 
TODOswitching languages? -->
<
html >
    <
head

and after this im loading my own jquery file.. so i think this is the problem

what is the best way to integrate the grceryCRUD output in my own sitetemplate?

 
Posted: 07 June 2011 02:00 PM   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
felix_ - 07 June 2011 05:38 PM

ah ok… the error comes from jquery 1.5.1 which ships with grocery crud…

Uncaught TypeError: Object [object Object] has no method ‘numeric’

i tried to integrate the template output in a normal view in my application but all the output for loading the jquery stuff is in front of my

<link type="text/css" rel="stylesheet" href="http://localhost/chesus/public/grocery_crud/themes/flexigrid/css/flexigrid.css" />
[removed]var base_url 'http://localhost/chesus/';[removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
    [removed][removed]
<style type='text/css'>
body
{
    font
-familyArial;
    
font-size14px;
}
a {
    color
blue;
    
text-decorationnone;
    
font-size14px;
}
a
:hover
{
    text
-decorationunderline;
}
</style>
    <
div></div>
    <
div style='height:20px;'></div>  
    <
div>
        <!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
<!-- 
TODOswitching languages? -->
<
html >
    <
head

and after this im loading my own jquery file.. so i think this is the problem

what is the best way to integrate the grceryCRUD output in my own sitetemplate?

This happens because you didn’t add the javascripts on the template . Every view of grocery crud uses jquery.  You have to read the http://www.grocerycrud.com/crud/view/codeigniter_installation (documentation to add your own template). If you have any problem with this tell me . There are many forum threads that have the same problem with you. Try to see the example of my simple custom-cms template, without yours .

 Signature 

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

 
Posted: 07 June 2011 02:41 PM   [ # 4 ]   [ Rating: 0 ]
Joined: 2011-01-19
39 posts

my problem is, that im using my own “template engine” .. not really an engine just a view which loads the header, adds the meta data etc
when i call render from the crud object all the content from the template is written BEFORE anything else is written to the html document
then all my stuff is coming and (why ever) the flexitable is written to the correct position in the document

i red the documentation on your website but i dont really get what i do wrong
maybe you can help me live via twitter, jabber, icq or whatever

greetz

 
Posted: 07 June 2011 11:54 PM   [ # 5 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
felix_ - 07 June 2011 06:41 PM

my problem is, that im using my own “template engine” .. not really an engine just a view which loads the header, adds the meta data etc
when i call render from the crud object all the content from the template is written BEFORE anything else is written to the html document
then all my stuff is coming and (why ever) the flexitable is written to the correct position in the document

i red the documentation on your website but i dont really get what i do wrong
maybe you can help me live via twitter, jabber, icq or whatever

greetz

Hello felix_ , I would like to help you via twitter , jabber etc but I really don’t have enough time. I am really busy the last days so I found a solution for you , hope its easy:
1st step comment your template. As you use your own “template” controller you will not need mine. So go to the contructor and comment the line

//$this->output->set_template('custom_cms'); 

(or whatever)
2nd Stepadd this 3 functions to your basic controller (I test this functions that works)

protected function _get_all_javascripts()
    

        
return $this->load->get_js_files();
    
}
    
    
protected function _get_all_css()
    

        
return $this->load->get_css_files();
    
}

    
protected function _get_all_views()
    

        $output 
$this->output->get_output();
//As you get the output you don't need anymore the output to view it automatically
        
$this->output->final_output '';
        return 
$output;
    

wherever you like.
3rd Step you can “take” what grocery crud do automatically to the template controller at your function . So for example at my employees_management function you will have:

function employees_management()
    
{
            $crud 
= new grocery_CRUD();

            
$crud->set_theme('datatables');
            
$crud->set_table('employees');
            
$crud->set_relation('officeCode','offices','city');
            
$crud->display_as('officeCode','Office City');
            
$crud->set_subject('Employee');
            
            
$crud->required_fields('lastName');
            
            
$crud->set_field_upload('file_url','public/uploads/files');
            
            
$crud->render();    

            
$js_array $this->_get_all_javascripts();
            
$css_array $this->_get_all_css();
            
$views $this->_get_all_views();
            
            
$data = array('js_array' => $js_array 'css_array' => $css_array'grocery_crud_as_string' => $views);
            
            
$this->load->view('my_custom_template',array('crud_data' => $data));
    

and the full controller (I just copied to understand exactly what I mean)

class Examples extends CI_Controller {

    
function __construct()
    
{
        parent
::__construct();
        
        
/* Standard Libraries */
        
$this->load->database();
        
$this->load->helper('url');
        
/* ------------------ */        
        
        
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');

        
//$this->output->set_template('custom_cms');        
        
        
$this->load->library('grocery_CRUD');    
    
}

    
function index()
    
{
        
    }
    
    
function employees_management()
    
{
            $crud 
= new grocery_CRUD();

            
$crud->set_theme('datatables');
            
$crud->set_table('employees');
            
$crud->set_relation('officeCode','offices','city');
            
$crud->display_as('officeCode','Office City');
            
$crud->set_subject('Employee');
            
            
$crud->required_fields('lastName');
            
            
$crud->set_field_upload('file_url','public/uploads/files');
            
            
$crud->render();    

            
$js_array $this->_get_all_javascripts();
            
$css_array $this->_get_all_css();
            
$views $this->_get_all_views();
            
            
$data = array('js_array' => $js_array 'css_array' => $css_array'grocery_crud_as_string' => $views);
            
            
$this->load->view('my_custom_template',array('crud_data' => $data));
    
}
    
    
protected function _get_all_javascripts()
    

        
return $this->load->get_js_files();
    
}
    
    
protected function _get_all_css()
    

        
return $this->load->get_css_files();
    
}

    
protected function _get_all_views()
    

        $output 
$this->output->get_output();
        
$this->output->final_output '';//As you get the output you don't need anymore the output to view it automatically
        
return $output;
    
}    
    
    
...........etc

hope that helps

 Signature 

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

 
Posted: 08 June 2011 05:58 AM   [ # 6 ]   [ Rating: 0 ]
Joined: 2011-01-19
39 posts

Hey,
i think thats the way i want to use your library but now i get a SQL error which wasnt before :/
part of my controller:

$this->load->database();
        
$this->load->helper('url');
        
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');
        
//$this->output->set_template('user');        
        
$this->load->library('grocery_CRUD');
        
        
$crud = new grocery_CRUD();
        
$crud->set_theme('datatables');
        
$this->grocery_crud->set_table('Users');
        
$this->grocery_crud->columns('username','email''newsletter''admin''premium''premiumEnd');
        
//$crud->set_field_upload('file_url','public/uploads/files');
        
        
$crud->render();
        
        
$data['js_array'$this->_get_all_javascripts();
        
$data['css_array'$this->_get_all_css();
        
$data['grocery_crud_as_string'$this->_get_all_views();
        
$data['main_content'"user/admin_test";
        
//$data['users'] = $users;
        
        
$this->load->view('templates/site_template'$data); 

and the 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 '' at line 1

SHOW COLUMNS FROM

Filename
xxx/www/no_www/application/third_party/grocery_crud/models/grocery_model.php

Line Number
226 
 
Posted: 08 June 2011 06:36 AM   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
felix_ - 08 June 2011 09:58 AM

Hey,
i think thats the way i want to use your library but now i get a SQL error which wasnt before :/
part of my controller:

$this->load->database();
        
$this->load->helper('url');
        
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');
        
//$this->output->set_template('user');        
        
$this->load->library('grocery_CRUD');
        
        
$crud = new grocery_CRUD();
        
$crud->set_theme('datatables');
        
$this->grocery_crud->set_table('Users');
        
$this->grocery_crud->columns('username','email''newsletter''admin''premium''premiumEnd');
        
//$crud->set_field_upload('file_url','public/uploads/files');
        
        
$crud->render();
        
        
$data['js_array'$this->_get_all_javascripts();
        
$data['css_array'$this->_get_all_css();
        
$data['grocery_crud_as_string'$this->_get_all_views();
        
$data['main_content'"user/admin_test";
        
//$data['users'] = $users;
        
        
$this->load->view('templates/site_template'$data); 

and the 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 '' at line 1

SHOW COLUMNS FROM

Filename
xxx/www/no_www/application/third_party/grocery_crud/models/grocery_model.php

Line Number
226 

This code :

$this->load->database();
        
$this->load->helper('url');
        
$this->load->add_package_path(APPPATH.'third_party/grocery_crud/');
        
//$this->output->set_template('user');        
        
$this->load->library('grocery_CRUD'); 
you must have it to your constructor and the
$crud = new grocery_CRUD();
        
$crud->set_theme('datatables');
        
$this->grocery_crud->set_table('Users');
        
$this->grocery_crud->columns('username','email''newsletter''admin''premium''premiumEnd');
        
//$crud->set_field_upload('file_url','public/uploads/files');
        
        
$crud->render();
        
        
$data['js_array'$this->_get_all_javascripts();
        
$data['css_array'$this->_get_all_css();
        
$data['grocery_crud_as_string'$this->_get_all_views();
        
$data['main_content'"user/admin_test";
        
//$data['users'] = $users;
        
        
$this->load->view('templates/site_template'$data); 

at a function of the cotrnoller . NOT ALL THE CODE to the constructor. See function employees_management() as I show you at the code up.

PS. Be careful because it is better for your table to have lower case characters (it is better “users” that “Users”)

 Signature 

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

 
Posted: 08 June 2011 06:42 AM   [ # 8 ]   [ Rating: 0 ]
Joined: 2011-01-19
39 posts

yeah thanks.. already noticed this and fixed it but didnt hit the “post” button here in forum :D

but i found something else which make some trouble:

Fatal errorCannot access protected property MY_Output::$final_output 

which happens in this line:

$this->output->final_output ''

so i had to make this variable public in the CI_Output Class

 
Posted: 08 June 2011 06:45 AM   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
felix_ - 08 June 2011 10:42 AM

yeah thanks.. already noticed this and fixed it but didnt hit the “post” button here in forum :D

but i found something else which make some trouble:

Fatal errorCannot access protected property MY_Output::$final_output 

which happens in this line:

$this->output->final_output ''

so i had to make this variable public in the CI_Output Class

OK wink If it works thats fine

 Signature 

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

 
Posted: 08 June 2011 06:47 AM   [ # 10 ]   [ Rating: 0 ]
Joined: 2011-01-19
39 posts

nah i dont think its the right way :D

didnt you get this error?
or whats the reason for this !?