EllisLab text mark
Advanced Search
3 of 23
3
   
v 1.3.3 grocery CRUD - an automatic Codeigniter CRUD
Posted: 20 April 2011 01:01 AM   [ Ignore ]   [ # 31 ]   [ Rating: 0 ]
Joined: 2010-11-27
30 posts

this is also good if can make new version to work with template (header, footer,..) and easy to merge with HMVC.

I love this plugin so much but difficult for me to enroll in HMVC.

 
Posted: 20 April 2011 01:30 AM   [ Ignore ]   [ # 32 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
tieungao - 20 April 2011 05:01 AM

this is also good if can make new version to work with template (header, footer,..) and easy to merge with HMVC.

I love this plugin so much but difficult for me to enroll in HMVC.

Its really worth it to learn to write in MVC . In the beginning it’s a little difficult but after you learn it , there is no way back to write php scripts from the scratch again grin.

I have a suggestion for you . I do it in many projects that don’t use frameworks or use another framework like kohana, cakephp etc. You can create a folder to your project . For example “admin” and copy all your codeigniter code there. So you have your project that works fine and you also have your administrator in codeigniter. Its really really easy (espacially with CI 2.0.0 that there is no need to config anything). The only config that you will add is the database config and the CRUD. That’s it.

I think its simple.

PS. grocery CRUD has template at templates/frontend/default/template.php

 Signature 

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

 
Posted: 22 April 2011 12:35 AM   [ Ignore ]   [ # 33 ]   [ Rating: 0 ]
Joined: 2009-10-16
3 posts

Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

Still Blank white in page ?...... any sugested what’s wrong in my styntac

 
Posted: 22 April 2011 03:14 AM   [ Ignore ]   [ # 34 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
Joker - 22 April 2011 04:35 AM

Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

Still Blank white in page ?...... any sugested what’s wrong in my styntac

The blank wepbage is because you have the error_reporting(0); Go to your index.php and change the error_reporting to E_ALL ( if you have 1.7.3 - 2.0.1) or define(‘ENVIRONMENT’, ‘development’); if you use 2.0.2 . Please do this first, because the error can be everywhere. If you are more specific I can help you. As you have seen ALL the code for the database is on the model. You are in the right place…

 Signature 

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

 
Posted: 22 April 2011 08:25 AM   [ Ignore ]   [ # 35 ]   [ Rating: 0 ]
Joined: 2011-04-22
1 posts

I just downloaded g-crud and now I have an error

Fatal error: Call to undefined method CI_Output::set_template() in C:\xampp\htdocs\test\application\controllers\crud.php on line 20

and line 20

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

how to solve it, any idea?

PS: I’m using CI 2.02

 
Posted: 22 April 2011 11:42 AM   [ Ignore ]   [ # 36 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
geaper - 22 April 2011 12:25 PM

I just downloaded g-crud and now I have an error

Fatal error: Call to undefined method CI_Output::set_template() in C:\xampp\htdocs\test\application\controllers\crud.php on line 20

and line 20

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

how to solve it, any idea?

PS: I’m using CI 2.02

You have to copy-paste all the files and not only the library.  This error means that you didn’t copy the folder core. And there I have MY_Output that have the function set_template

 Signature 

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

 
Posted: 22 April 2011 12:56 PM   [ Ignore ]   [ # 37 ]   [ Rating: 0 ]
Joined: 2009-10-16
3 posts
web-johnny - 22 April 2011 07:14 AM
Joker - 22 April 2011 04:35 AM

Great work for u grad.. for mysql doing great on my application, but when i transfer to mssql default driver from ci i got blank white page when access the function ..

For mssql i got make change for SET NAMES = UTF8 (i don’t know how to replace on mssql ) and

SHOW Column , when looks select data type from tabel .... i make view on mssql with but i exec With EXEC SHOW COLUMN

Still Blank white in page ?...... any sugested what’s wrong in my styntac

The blank wepbage is because you have the error_reporting(0); Go to your index.php and change the error_reporting to E_ALL ( if you have 1.7.3 - 2.0.1) or define(‘ENVIRONMENT’, ‘development’); if you use 2.0.2 . Please do this first, because the error can be everywhere. If you are more specific I can help you. As you have seen ALL the code for the database is on the model. You are in the right place…

Thanks for quick answer ,... i will try your suggestion, yup the error was on the model , when SET NAMES = UTF8 firts error (i was disable it) after that on SHOW COLUMN for looking Structure of table (i create view on mssql with name Show_column)i change with EXE Show_column ‘table_name’
After that was blank ....

OK i will inform next ...


Hem the result was
“Fatal error: Cannot access empty property in I:\susilo\xampp\htdocs\crudme\application\third_party\grocery_crud\libraries\grocery_crud.php on line 852

maybe can u try it


CREATE procedure [dbo].[Show_Columns]
(
  @table_name       nvarchar(384)
) as
begin
  Select
  column_name as Field,
  data_type+cast(’(’ as varchar)+cast(character_maximum_length as varchar)+cast(’)’ as varchar) as ‘Type’,
  is_nullable as ‘Null’,
  ‘’ as ‘Key’,
  column_default as ‘Default’,
  ‘’ as Extra
  from information_schema.columns WHERE table_name = @table_name
end

the result was like SHOW COLUMN on mysql…

now need help about it

 
Posted: 22 April 2011 04:46 PM   [ Ignore ]   [ # 38 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts

I didn’t tested in mssql . I worked with mssql and only with visual studio and linq is good . Without this really I hate MSSQL and I didn’t tested on it. I didn’t even install it on my computer . Sorry…
But why you use mssql ? Ok if you find the problem please send it to me (just post the code of the model) , so and other people knows about this.

Thank you very much

 Signature 

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

 
Posted: 22 April 2011 11:43 PM   [ Ignore ]   [ # 39 ]   [ Rating: 0 ]
Joined: 2009-10-16
3 posts
web-johnny - 22 April 2011 08:46 PM

I didn’t tested in mssql . I worked with mssql and only with visual studio and linq is good . Without this really I hate MSSQL and I didn’t tested on it. I didn’t even install it on my computer . Sorry…
But why you use mssql ? Ok if you find the problem please send it to me (just post the code of the model) , so and other people knows about this.

Thank you very much

I know i got bad choice when i chosee mssql for this project.

ok the model


function __construct()
  {
      parent::__construct();
     
      $this->db->query(‘set names utf8’); === this line made the firts error
  }


then i disable it () i didn’t made change just // next it


after then this function

  function get_field_types_basic_table()
  {
      $db_field_types = array();
    //foreach($this->db->query(“SHOW COLUMNS FROM {$this->table_name}”)->result() as $db_field_type)
 
  foreach($this->db->query(“EXEC Show_Columns {$this->table_name}”)->result() as $db_field_type)
     
      {

        $type = explode(”(”,$db_field_type->Type);
        $db_type = $type[0];
       
        if(isset($type[1]))
        {
          $length = substr($type[1],0,-1);
        }
        else
        {
          $length = ‘’;
        }
        $db_field_types[$db_field_type->Field][‘db_max_length’] = $length;
        $db_field_types[$db_field_type->Field][‘db_type’] = $db_type;
        $db_field_types[$db_field_type->Field][‘db_null’] = $db_field_type->Null;
        $db_field_types[$db_field_type->Field][‘db_default’] = $db_field_type->Default;
        $db_field_types[$db_field_type->Field][‘db_extra’] = $db_field_type->Extra;
      }
 
the blue was the originial made change with the red one

i made some procedure on mssql like i sad before

after that

was on lib

line 852

=====
protected function showList($ajax = false)
  {
      $ci = &get;_instance();
     
      $data = $this->get_common_data();
     
      $data->order_by   = $this->order_by;
     
      $data->types       = $this->get_field_types();
     
      $data->list = $this->get_list();
      $data->list = $this->change_list($data->list , $data->types);
     
      $data->total_results = $this->get_total_results();
     
      $data->columns           = $this->get_columns();
      $data->primary_key         = $this->get_primary_key();
      $data->add_url           = $this->getAddUrl();
      $data->edit_url           = $this->getEditUrl();
      $data->delete_url         = $this->getDeleteUrl();
      $data->ajax_list_url     = $this->getAjaxListUrl();
      $data->ajax_list_info_url   = $this->getAjaxListInfoUrl();
     
      $data->unset_add         = $this->unset_add;
      $data->unset_edit         = $this->unset_edit;
      $data->unset_delete         = $this->unset_delete;
     
      if($data->list === false)
      {
        throw new Exception(‘It is impossible to get data. Please check your model and try again.’, 13);
        $data->list = array();
      }
     
      foreach($data->list as $num_row => $row)
      {
        $data->list[$num_row]->edit_url = $data->edit_url.’/’.$row->{$data->primary_key};
        $data->list[$num_row]->delete_url = $data->delete_url.’/’.$row->{$data->primary_key};
      }
     
      if(!$ajax)
      {
        $data->list_view = $this->_theme_view(‘list.php’,$data,true);
        $this->_theme_view(‘list_template.php’,$data); 
      }
      else
      {
        $ci->output->unset_template();
        $this->_theme_view(‘list.php’,$data);
      }
  }
 

I think ... i was enable read from the model that i was made EXEC show_column

NOt like Show Column on Mysql


ok that was i found on mssql

thank’s

maybe other can help this great crud u have made

 
Posted: 25 April 2011 10:04 AM   [ Ignore ]   [ # 40 ]   [ Rating: 0 ]
Joined: 2010-10-06
117 posts

Ok, I’ve found this amazing tool and trying to use in my development but I’m doing something wrong because don’t work. See what I’ve done until now:
1. Load needed libraries in __construct() (The other libraries needed are autoloaded).

public function __construct() {
      parent
::__construct();
      
$this->load->add_package_path(APPPATH 'third_party/grocery_crud/');
      
$this->output->set_template('custom_cms');
      
$this->load->library('grocery_CRUD');

2. Write this piece of code in index():

public function index() {
      
if ($this->my_usession->logged_in{
      $this
->grocery_crud->set_table('trasegados')
                 ->
set_subject('Trasegados')
                 ->
columns('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->fields('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->required_fields('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->render();
         
$this->load->view('trasegados/form'$data);
      
else {
         redirect
('user/login');
      
}
   } 

3. Echo $output at trasegados/form template:

<?php $this->load->view('layout_login_header'); ?>
<?php 
echo $output ?>
<?php $this
->load->view('layout_login_footer'); ?> 

4. Add the needed code at layout_login_header:

<?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; ?> 

But I got a lot of errors:

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: css

Filename: views/layout_login_header.php

Line Number: 11

A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/layout_login_header.php

Line Number: 11
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: js

Filename: views/layout_login_header.php

Line Number: 15
A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: views/layout_login_header.php

Line Number: 15

See the entire output image here http://www.dropmocks.com/mUTRR Why t.his? What I’m doing wrong?

Cheers and thanks

 
Posted: 25 April 2011 10:15 AM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts

To your template you must write this :

<?php $this->load->view('layout_login_header', array('css' => $css'js' => $js)); ?>
<?php 
echo $output ?>
<?php $this
->load->view('layout_login_footer'); ?> 

I think the wrong is only in the $this->load->view(‘layout_login_header’); . Hope this will solve your problem

 Signature 

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

 
Posted: 25 April 2011 10:17 AM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Joined: 2010-10-06
117 posts

Nope :( I changed as you suggest and still no working

 
Posted: 25 April 2011 10:26 AM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts

Ok I think I find it grin
You will not use the view $this->load->view(‘trasegados/form’, $data);
You have to this code to your template : (templates/frontend/custom-cms/template.php). So your template will be something like the template below: (the application/views/ is needed in the template, I still don’t know why)

<?php $this->load->view('application/views/layout_login_header', array('css' => $css'js' => $js)); ?>
<?php 
echo $output ?>
<?php $this
->load->view('application/views/layout_login_footer'); ?> 

delete you line $this->load->view(‘trasegados/form’, $data);  and if you want to add more views you can do it like this…

function test()
{
    $this
->load->view(...); // for a view before the crud
    
$this->grocery_crud->....
    
$this->grocery_crud->render();

    
$this->load->view(...); // for a view after the crud

and your index function will be like this:

public function index() {
      
if ($this->my_usession->logged_in{
      $this
->grocery_crud->set_table('trasegados')
                 ->
set_subject('Trasegados')
                 ->
columns('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->fields('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->required_fields('inicio_91''fin_91''total_91''inicio_95''fin_95''total_95''inicio_diesel''fin_diesel''total_diesel''id_estacion''usuario');
         
$this->grocery_crud->render();
         
//$this->load->view('trasegados/form', $data);
      
else {
         redirect
('user/login');
      
}
   } 
 Signature 

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

 
Posted: 25 April 2011 10:32 AM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Joined: 2010-10-06
117 posts

Hmmm OK, this solve the problem but what about my layout? Now I’m only have the CRUD and I want, of course, the layout working togheter. Any way? Also I can see that you use Flexigrid wink where I can change default settings? I don’t want this to be collapsible

Cheers and thanks for your support

 
Posted: 25 April 2011 10:40 AM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Avatar
Joined: 2010-12-18
244 posts
ReyPM - 25 April 2011 02:32 PM

Hmmm OK, this solve the problem but what about my layout? Now I’m only have the CRUD and I want, of course, the layout working togheter. Any way? Also I can see that you use Flexigrid wink where I can change default settings? I don’t want this to be collapsible

Cheers and thanks for your support

To your layout you can use your own template . For example in you layout_login_header you can have ( I just copy paste the home page of codeigniter ):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"

<
html 
<
head
    <
meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
    <
title>CodeIgniter Open source PHP web application framework</title
    
    <
link rel="shortcut icon" href="/images/design/favicon.ico" type="image/x-icon" /> 
    <
link rel="home" href="http://codeigniter.com/" title="Home" /> 
 
    <
link rel="stylesheet" href="http://codeigniter.com/?css=global/styles.css.v.1296267222" type="text/css" media="screen, projection" charset="utf-8" /> 
    <
link rel="stylesheet" href="http://codeigniter.com/?css=global/sIFR-screen.css.v.1284169231" type="text/css" media="screen, projection" charset="utf-8" /> 
    <
link rel="stylesheet" href="http://codeigniter.com/?css=global/sIFR-print.css.v.1284169231" type="text/css" media="print" charset="utf-8" /> 
 
    <
meta name="MSSmartTagsPreventParsing" content="true" /> 
    <
meta http-equiv='expires' content='-1' /> 
    <
meta http-equiv='pragma' content='no-cache' /> 
    <
meta name='robots' content='all' /> 
    <
meta name='description' content='CodeIgniter: an open source Web Application Framework that helps you write PHP programs' /> 
    <
meta name="keywords" content="EllisLab CodeIgniter PHP CMS Content Management System software framework " /> 
    
    <!-- 
REQUIRED CODE goes here-->
    <!-- 
END OF REQUIRED CODE-->

        <!-- 
Reverse Links from EllisLab network sites -->        
    <
link rev="expressionengine" href="http://expressionengine.com/"
    
title="The most flexible publishing system you'll ever meet" /> 
    
    <
link rev="pmachinepro" href="http://pmachinepro.com/"
    
title="Flexible and free blogging system that supports advanced features like multiple blogs, moblogging, and much more" /> 
    
    <
link rev="ellislab" href="http://ellislab.com/"
    
title="Where ideas hatch!" /> 
    
    <
link rev="enginehosting" href="http://enginehosting.com/"
    
title="High performance web hosting" /> 
 
        <
link rel="shortcut icon" href="/images/design/favicon.ico" type="image/x-icon" /> 
    
    
[removed][removed] 
    [removed] 
      
var scene {
        src
'/images/sifr/scene.swf'
      
};
      
sIFR.delayCSS  true;
      
sIFR.activate(scene);
      
sIFR.replace({selector'h3' ,src'/images/sifr/scene.swf' ,wmode:'transparent',css'.sIFR-root''color''#FF3C00' }  }  });
    
[removed] 
<link rel="alternate" type="application/atom+xml" title="Master Atom feed" href="http://codeigniter.com/feeds/atom/full/" /> 
<
link rel="alternate" type="application/rss+xml" title="Master RSS feed" href="http://codeigniter.com/feeds/rss/full/" /> 
</
head
 
<
body id="home"
 
    <
div id="masthead"
        <
a href="http://ellislab.com/"><img src="/images/design/ellislab_network.gif" width="287" height="23" alt="Part of the EllisLab Network" /></a
    </
div
    
 
    <
div id="header"
    <
div id="login"
                <
a href="http://ellislab.com/forums/member/login/">Login</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="http://ellislab.com/forums/member/register/">Register</a
        </
div
    <
h1><a href="/" title="CodeIgniter"><img src="/images/design/ci_logo2.gif" alt="CodeIgniter" width="170" height="73" /></a></h1
</
div
 
 
    <
div id="siteNav"
    <
ul
        <
li id="homenav"><a href="http://codeigniter.com/">Home</a></li
        <
li id="downloadsnav"><a href="http://codeigniter.com/downloads/">Downloads</a></li
        <
li id="newsnav"><a href="http://codeigniter.com/news/">News</a></li
        <
li id="tutorialnav"><a href="http://codeigniter.com/tutorials/">VideoTutorials</a></li
        <
li id="manualnav"><a href="http://ellislab.com/codeigniter/user-guide/">User&nbsp;Guide</a></li
        <
li id="forumnav"><a href="http://ellislab.com/forums/">Forums</a></li
        <
li id="wikinav"><a href="http://codeigniter.com/wiki/">Wiki</a></li
        <
li id="bugnav"><a href="http://bitbucket.org/ellislab/codeigniter-reactor/issues?kind=bug">Bug Tracker</a></li
    </
ul
    <
div class="clear"></div
</
div
    
    <!-- 
Candy comes in a wrapper --> 
    <
div id="wrapperWit"
 Signature 

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

 
3 of 23
3