Jump to content


How to use Grocery CRUD and Image CRUD together?

grocery crud image multiple upload

  • Please log in to reply
46 replies to this topic

#21 maha

maha

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationEgypt

Posted 13 February 2013 - 01:29 PM

i need it also.

i don't know how to use image crud with add action ?

can any one show me please?



#22 maha

maha

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationEgypt

Posted 14 February 2013 - 07:18 AM

hi  i used it with add action successfully .

but i have question:

how can i determine  the image extensions (jpg ,png,....).

and how can i use     callback_before_delete & set_language functions?
 



#23 maha

maha

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationEgypt

Posted 14 February 2013 - 08:15 AM

any help??



#24 MarkC

MarkC

    Member

  • Members
  • PipPip
  • 22 posts

Posted 14 February 2013 - 08:33 AM

hi  i used it with add action successfully .

but i have question:

how can i determine  the image extensions (jpg ,png,....).

and how can i use     callback_before_delete & set_language functions?
 

 

Can you show me how you did that? Maybe I would be able to solve the rest...



#25 maha

maha

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationEgypt

Posted 14 February 2013 - 08:37 AM

OK her it's


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

        $crud->set_table('photos');
        $crud->columns('Name','Category_ID','Image');
       $crud->set_field_upload('Image', 'assets/uploads/thumb/');
       $crud->add_action('more_images', base_url().'assets/template/images/add_image.png', '' ,'ui-icon-plus',array($this,'gallery'));
        $output = $crud->render();
        $this->_output_data($output);
        
    }
public function gallery($primary_key , $row) {
	   return site_url('Admin/image/management/'.$row->Category_ID);
	  
    }	

image/management

function management()
    {
        $c = new image_CRUD();
        $c->set_table('photos');    //-- Set the table name of photo gallery
        $c->set_primary_key_field('ID');
        $c->set_url_field('Image');   //--Set the url field name that you want to store the image name
         $c->set_ordering_field('ID'); //--set the table field that is responsible for the ordering.
        $c->set_image_path('assets/uploads/thumb');   
       	$c->set_relation_field('Category_ID');
      //$c->set_language(lang('Adminlang'));
        
	
        
        $output = $c->render();
        $this->_output_data($output);
        
		
    }


#26 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 14 February 2013 - 10:28 AM

Dear fellow developers, it seems that I don't have enough time to play around with this issue.

The following dropbox link contains a 7zipped file with the installation as it stands now on: http://eletter.gr/samples/gc_ic2

Under application/controllers/ open the gc_examples.php controller and the function example1_gc.

In this function we have a full integration of grocery crud/image crud together at the same time on the same view, as it is showed here, http://eletter.gr/sa...les/example1_gc

For your information, the integrity of the two libraries, grocery crud and image crud remains intact, this means that no changes to the core files have been made.

The only change that has taken place is on the list.php view of the image crud, assets/image_crud/views/list.php where

lines 5,6 have been commented out,

 

//$this->set_js('assets/image_crud/js/jquery-1.8.2.min.js');
//$this->set_js('assets/image_crud/js/jquery-ui-1.9.0.custom.min.js');
 
I hope somebody can take it from there and carry on!

As I have explained on a previous post the idea is not to change anything on the libraries themselves and have both grocery and image crud at the same time together.

For example, if a site viewer browses the gallery (not logged in as an administrator) can see something like the simple gallery (http://eletter.gr/sa...e_photo_gallery)

If he logs in as an administrator then he can have the full view as it stands right now on : http://eletter.gr/sa...les/example1_gc

If somebody has time, he could extend it in a way that the main db holds more information like albums(another table), or even users' albums in a multiuser environment.

The available options are endless to be honest!

 

So here is the link:

https://dl.dropbox.c...image_in_one.7z

 

P.S. on the root there is the gz file from phpmyadmin in order to setup your database, samples_gc_ic.sql.gz

 

I hope this helps somebody! Good luck.

 

UPDATE: Using the attached code and the ability of image crud to multiple upload then we can have a fully featured album/gallery to be used by anyone in any environment, even if it is single or multi user environment (by using the suggested as I mentioned before).

 

hi  i used it with add action successfully .

but i have question:

how can i determine  the image extensions (jpg ,png,....).

and how can i use     callback_before_delete & set_language functions?
 

 

 

OK her it's


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

        $crud->set_table('photos');
        $crud->columns('Name','Category_ID','Image');
       $crud->set_field_upload('Image', 'assets/uploads/thumb/');
       $crud->add_action('more_images', base_url().'assets/template/images/add_image.png', '' ,'ui-icon-plus',array($this,'gallery'));
        $output = $crud->render();
        $this->_output_data($output);
        
    }
public function gallery($primary_key , $row) {
	   return site_url('Admin/image/management/'.$row->Category_ID);
	  
    }	

image/management

function management()
    {
        $c = new image_CRUD();
        $c->set_table('photos');    //-- Set the table name of photo gallery
        $c->set_primary_key_field('ID');
        $c->set_url_field('Image');   //--Set the url field name that you want to store the image name
         $c->set_ordering_field('ID'); //--set the table field that is responsible for the ordering.
        $c->set_image_path('assets/uploads/thumb');   
       	$c->set_relation_field('Category_ID');
      //$c->set_language(lang('Adminlang'));
        
	
        
        $output = $c->render();
        $this->_output_data($output);
        
		
    }

 

 

Can you show me how you did that? Maybe I would be able to solve the rest...


Edited by David Oster, 14 February 2013 - 10:50 AM.

____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#27 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 14 February 2013 - 10:39 AM

To limit Grocery's permitted files you need to go under application/config/grocery_crud.php

To limit Image's you need to change the core library file under applications/libraries/image_crud.php in a couple of places, 

1. protected function _upload_file($upload_dir) 

2. private function trim_file_name($name, $type)


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#28 Antonio Giungato

Antonio Giungato

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 14 February 2013 - 12:07 PM

Thank you very much David!



#29 MarkC

MarkC

    Member

  • Members
  • PipPip
  • 22 posts

Posted 14 February 2013 - 01:57 PM

Dear fellow developers, it seems that I don't have enough time to play around with this issue.

The following dropbox link contains a 7zipped file with the installation as it stands now on: http://eletter.gr/samples/gc_ic2

Under application/controllers/ open the gc_examples.php controller and the function example1_gc.

In this function we have a full integration of grocery crud/image crud together at the same time on the same view, as it is showed here, http://eletter.gr/sa...les/example1_gc

For your information, the integrity of the two libraries, grocery crud and image crud remains intact, this means that no changes to the core files have been made.

The only change that has taken place is on the list.php view of the image crud, assets/image_crud/views/list.php where

lines 5,6 have been commented out,

 

//$this->set_js('assets/image_crud/js/jquery-1.8.2.min.js');
//$this->set_js('assets/image_crud/js/jquery-ui-1.9.0.custom.min.js');
 
I hope somebody can take it from there and carry on!

As I have explained on a previous post the idea is not to change anything on the libraries themselves and have both grocery and image crud at the same time together.

For example, if a site viewer browses the gallery (not logged in as an administrator) can see something like the simple gallery (http://eletter.gr/sa...e_photo_gallery)

If he logs in as an administrator then he can have the full view as it stands right now on : http://eletter.gr/sa...les/example1_gc

If somebody has time, he could extend it in a way that the main db holds more information like albums(another table), or even users' albums in a multiuser environment.

The available options are endless to be honest!

 

So here is the link:

https://dl.dropbox.c...image_in_one.7z

 

P.S. on the root there is the gz file from phpmyadmin in order to setup your database, samples_gc_ic.sql.gz

 

I hope this helps somebody! Good luck.

 

UPDATE: Using the attached code and the ability of image crud to multiple upload then we can have a fully featured album/gallery to be used by anyone in any environment, even if it is single or multi user environment (by using the suggested as I mentioned before).

 

Hello David,

 

Can you just show me where to click to see how uploading of images works?



#30 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 14 February 2013 - 02:28 PM

Sorry guys!!! I forgot to change the language interface of the library! It's english now!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#31 maha

maha

    Advanced Member

  • Members
  • PipPipPip
  • 80 posts
  • LocationEgypt

Posted 16 February 2013 - 01:20 PM

i use it but it makes some errors,

so i returned back to add_action case.

but there is a problem ,

h want to make 2 conditions (how it come).

i.e.

like that

function management()
    {
        $c = new image_CRUD();
        $c->set_table('photos');  
        $c->set_primary_key_field('ID');
        $c->set_url_field('Image');   
       // $c->set_title_field('title'); 
        $c->set_ordering_field('ID'); 
        $c->set_image_path('assets/uploads');   
       	$c->set_relation_field('Category_ID');
	$c->set_relation_field('Year'');
    
        $output = $c->render();
        $this->_output_data($output);
        
		
    }

i know it's wrong to use

    $c->set_relation_field('Category_ID');

but i want to make another condition.

any help??



#32 MarkC

MarkC

    Member

  • Members
  • PipPip
  • 22 posts

Posted 19 February 2013 - 12:52 AM

I really didn't get this to work.

 

I have another question. Can this plugin jQuery File Upload integrate somehow with grocery crud?

 

http://blueimp.githu...ry-File-Upload/



#33 Alfonso A Secas

Alfonso A Secas

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 21 February 2013 - 09:03 PM

Hi, this is my working solution: 

 

- In the add and edit files, put an iframe that points your image-crud part, just over the save/cancel buttons or wherever you want to manage the images.

- You can adapt the iframe's height as you add or delete rows of images, calling a js function declared outside the iframe, from inside the iframe ( parent.myResizeFunction() )  in two situations: <body onload="parent.myResizeFunction()... and every time image list is updated (/assets/image_crud/views/list.php about line 36, on "complete" function)

 

As there's a 1-n relation between the table record and the images we set $image_crud->set_relation_field('myField');. The value of this field is passed to the image crud in the url (see example_3). But when we are adding a new record we still don't have this value, so I'm using a very high value like 99999 as a temporary value. When saving new record, I use a callback_after_insert which second parameter gives me the new insert_id, then I update the temporary value in my images table.

 

When editing a record, get the current ID from $this->getStateInfo(); to compose the iframe's source url.

 

This solution doesn't change any core file. I don't like using iframes and functions calling iframe's parent... but it's easy to implement and it does the job. 



#34 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 21 February 2013 - 10:18 PM

This is nice!

Another way of doing it.

Could you share an example code?

 

Hi, this is my working solution: 

 

- In the add and edit files, put an iframe that points your image-crud part, just over the save/cancel buttons or wherever you want to manage the images.

- You can adapt the iframe's height as you add or delete rows of images, calling a js function declared outside the iframe, from inside the iframe ( parent.myResizeFunction() )  in two situations: <body onload="parent.myResizeFunction()... and every time image list is updated (/assets/image_crud/views/list.php about line 36, on "complete" function)

 

As there's a 1-n relation between the table record and the images we set $image_crud->set_relation_field('myField');. The value of this field is passed to the image crud in the url (see example_3). But when we are adding a new record we still don't have this value, so I'm using a very high value like 99999 as a temporary value. When saving new record, I use a callback_after_insert which second parameter gives me the new insert_id, then I update the temporary value in my images table.

 

When editing a record, get the current ID from $this->getStateInfo(); to compose the iframe's source url.

 

This solution doesn't change any core file. I don't like using iframes and functions calling iframe's parent... but it's easy to implement and it does the job. 


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#35 Robert

Robert

    Advanced Member

  • Members
  • PipPipPip
  • 220 posts

Posted 10 June 2013 - 10:46 AM

Hi, this is my working solution: 

 

- In the add and edit files, put an iframe that points your image-crud part, just over the save/cancel buttons or wherever you want to manage the images.

- You can adapt the iframe's height as you add or delete rows of images, calling a js function declared outside the iframe, from inside the iframe ( parent.myResizeFunction() )  in two situations: <body onload="parent.myResizeFunction()... and every time image list is updated (/assets/image_crud/views/list.php about line 36, on "complete" function)

 

As there's a 1-n relation between the table record and the images we set $image_crud->set_relation_field('myField');. The value of this field is passed to the image crud in the url (see example_3). But when we are adding a new record we still don't have this value, so I'm using a very high value like 99999 as a temporary value. When saving new record, I use a callback_after_insert which second parameter gives me the new insert_id, then I update the temporary value in my images table.

 

When editing a record, get the current ID from $this->getStateInfo(); to compose the iframe's source url.

 

This solution doesn't change any core file. I don't like using iframes and functions calling iframe's parent... but it's easy to implement and it does the job. 

 

 

 

can you post the code for us to see i need to use this to



#36 JpunkLy

JpunkLy

    Member

  • Members
  • PipPip
  • 15 posts

Posted 17 June 2013 - 07:46 PM

I'm Confused with function set_relation_n_n();

please....help me.....to Explain..... :D  :D  :D  :D


Visit My Page -> http://nugashare.me.pn |  @DianNugraha702


#37 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 19 June 2013 - 10:10 PM

I'm Confused with function set_relation_n_n();

please....help me.....to Explain..... :D  :D  :D  :D

 

 

The example is quite self explanatory. Study it along with the code and make some examples of yourself to see what happens.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#38 MSuprayogie KivaHeatnix

MSuprayogie KivaHeatnix

    Member

  • Members
  • PipPip
  • 13 posts

Posted 21 June 2013 - 03:20 AM

http://eletter.gr/sa...les/example1_gc

 

 

 

can u share d code ?



#39 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 21 June 2013 - 11:41 PM

http://eletter.gr/sa...les/example1_gc

 

 

 

can u share d code ?

the code is here.


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#40 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 21 June 2013 - 11:44 PM

Dear fellow developers, it seems that I don't have enough time to play around with this issue.

The following dropbox link contains a 7zipped file with the installation as it stands now on: http://eletter.gr/samples/gc_ic2

Under application/controllers/ open the gc_examples.php controller and the function example1_gc.

In this function we have a full integration of grocery crud/image crud together at the same time on the same view, as it is showed here, http://eletter.gr/sa...les/example1_gc

For your information, the integrity of the two libraries, grocery crud and image crud remains intact, this means that no changes to the core files have been made.

The only change that has taken place is on the list.php view of the image crud, assets/image_crud/views/list.php where

lines 5,6 have been commented out,

 

//$this->set_js('assets/image_crud/js/jquery-1.8.2.min.js');
//$this->set_js('assets/image_crud/js/jquery-ui-1.9.0.custom.min.js');
 
I hope somebody can take it from there and carry on!

As I have explained on a previous post the idea is not to change anything on the libraries themselves and have both grocery and image crud at the same time together.

For example, if a site viewer browses the gallery (not logged in as an administrator) can see something like the simple gallery (http://eletter.gr/sa...e_photo_gallery)

If he logs in as an administrator then he can have the full view as it stands right now on : http://eletter.gr/sa...les/example1_gc

If somebody has time, he could extend it in a way that the main db holds more information like albums(another table), or even users' albums in a multiuser environment.

The available options are endless to be honest!

 

So here is the link:

https://dl.dropbox.c...image_in_one.7z

 

P.S. on the root there is the gz file from phpmyadmin in order to setup your database, samples_gc_ic.sql.gz

 

I hope this helps somebody! Good luck.

 

UPDATE: Using the attached code and the ability of image crud to multiple upload then we can have a fully featured album/gallery to be used by anyone in any environment, even if it is single or multi user environment (by using the suggested as I mentioned before).


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr






Also tagged with one or more of these keywords: grocery, crud, image, multiple, upload

2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users