⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to use Grocery CRUD and Image CRUD together?



MarkC

MarkC
  • profile picture
  • Member

Posted 07 February 2013 - 00:46 AM

I'm fascinated of Grocery Crud and how easy is it to work with it. I need to use multiple image gallery upload. There is a table Products with 10-15 columns + 4 n-n relations, and finally I have to  add functionality the user to be able to upload one main image, and 8 images for the gallery.

 

How can I do this with grocery crud and image crud? I don't know where to start and how to make them work together. I imagine there will be some field at the bottom and there should be the images dragged or manually selected with a button click and uploaded...

 

Any help is appreciated.

 

P.S. I don't know if I can open another topic, but I want to make the interface a little more prettier so are there some themes I can choose, or I should create something mine?


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 06:29 AM

Check this out: /topic/624-grocery-crud-w-image-crud-to-work-in-ie/

The whole idea behind it is to use the add_action to the place you need and this will fire-up the image crud library!

 

as for your P.S. grocery crud currently(development version only) supports 3 themes, felxigrid, datatables and twitter-bootstrap(not documented on the documentation yet, http://www.grocerycrud.com/documentation/options_functions/set_theme)


MarkC

MarkC
  • profile picture
  • Member

Posted 07 February 2013 - 09:28 AM

Check this out: /topic/624-grocery-crud-w-image-crud-to-work-in-ie/

The whole idea behind it is to use the add_action to the place you need and this will fire-up the image crud library!

 

as for your P.S. grocery crud currently supports 3 themes, felxigrid, datatables and twitter-bootstrap(not documented on the documentation yet, http://www.grocerycrud.com/documentation/options_functions/set_theme)

 

I will need a little help please. I read the first topic you sent me, but there is just that the IE bug was fixed, not a single clue or line of code where and how should I write. I just don't know how to start... Is it possible the image gallery uploading to be in the same view when I'm adding a new product through Grocery CRUD or it has to be separate? The user will have to enter the details for the product, save the product, press go back, find the product in the list and click Add gallery for example? Can this everything be in one single view?

 

P.S. How can use bootstrap theme? I really want to see how it looks like :)


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 12:53 PM

I will try to make an example integrating grocery crud and image crud and I'll post the example, but this will be next week since I am busy!


MarkC

MarkC
  • profile picture
  • Member

Posted 07 February 2013 - 12:57 PM

I will try to make an example integrating grocery crud and image crud and I'll post the example, but this will be next week since I am busy!

 

Great.


MarkC

MarkC
  • profile picture
  • Member

Posted 07 February 2013 - 13:05 PM

I will try to make an example integrating grocery crud and image crud and I'll post the example, but this will be next week since I am busy!

 

Can you just tell me how to use the Bootstrap theme?


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 13:47 PM

If you check the development version on git hub (line 2 of the change_log.txt) you will see that the bootstrap theme has been implemented om the latest development version(1.4).

Hence you need to download the development version in order to use it. This version is not yet available to the general public and it might contain bugs!!!


MarkC

MarkC
  • profile picture
  • Member

Posted 07 February 2013 - 14:10 PM

I see. I will wait for the final version. Is there some predictions when is it going to be released?


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 14:39 PM

We don't know!!! I think even [member="web-johnny"] doesn't know when he will freeze the development of 1.4 and release it!!!


Antonio Giungato

Antonio Giungato
  • profile picture
  • Member

Posted 07 February 2013 - 16:33 PM

I'd love to see an example of grocery crud and image crud integration too!


victor

victor
  • profile picture
  • Member

Posted 07 February 2013 - 20:29 PM

I seem we need to change the image crud core because it use the same segments which GC use. when I'll have a time I make a library. but I don't know when it will be )

davidoster

davidoster
  • profile picture
  • Member

Posted 08 February 2013 - 00:42 AM

I'm fascinated of Grocery Crud and how easy is it to work with it. I need to use multiple image gallery upload. There is a table Products with 10-15 columns + 4 n-n relations, and finally I have to  add functionality the user to be able to upload one main image, and 8 images for the gallery.

 

How can I do this with grocery crud and image crud? I don't know where to start and how to make them work together. I imagine there will be some field at the bottom and there should be the images dragged or manually selected with a button click and uploaded...

 

Any help is appreciated.

 

P.S. I don't know if I can open another topic, but I want to make the interface a little more prettier so are there some themes I can choose, or I should create something mine?

 

[member=MarkC] please post the sql of the table products so I can make a real life example.


MarkC

MarkC
  • profile picture
  • Member

Posted 08 February 2013 - 09:52 AM

Table Products, this is the main table.

 

id 	INT
name 	VARCHAR
company 	TINYINT
code 	INT
date_register 	DATE
date_change 	DATE
main_picture 	VARCHAR
short_description 	VARCHAR
price 	INT
views 	INT
country 	TINYINT
warranty 	TINYINT
stock	BOOLEAN
active	BOOLEAN

I have other tables for 1-N relation, for Countries and Company

 

$crud->set_relation('company', 'companies', 'name_of_company');
$crud->set_relation('country', 'countries', 'name_of_countries');

And I have a few N-N relations

$crud->set_relation_n_n('Categories', 'pr_cat', 'category', 'id_pr', 'id_cat', 'name_cat', 'something');
$crud->set_relation_n_n('Materials', 'pr_mat', 'material', 'id_pr', 'id_mat', 'name_mat');
$crud->set_relation_n_n('Colors', 'pr_col', 'color', 'id_pr', 'id_col', 'name_col');
$crud->set_relation_n_n('Cities', 'pr_city', 'city', 'id_pr', 'id_city', 'name_city');

 

I don't know if I should keep separately Main Picture field, or the first uploaded picture will be the main? I still haven't seen how the Image CRUD works. I plan to add 8 columns more for picture 1-8 in the first table Products and put there the image name. I also want to generate image thumbnails right after the upload, and put them in the appropriate folder.

 

I hope you understand everything I said, I changed the column names in English so you will better understand.


MarkC

MarkC
  • profile picture
  • Member

Posted 08 February 2013 - 10:05 AM

Here is what I have used for another project for the Image thumbnails generate function.

 

function example_callback_after_upload($uploader_response,$field_info, $files_to_upload)
    {
        $this->load->library('image_moo');
             
        //Is only one file uploaded so it ok to use it with $uploader_response[0].
        $file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
        $new1 = 'pictures/350x210/'.$uploader_response[0]->name;
        $new2 = 'pictures/280x168/'.$uploader_response[0]->name;
        $new3 = 'pictures/196x118/'.$uploader_response[0]->name;
        $new4 = 'pictures/120x72/'.$uploader_response[0]->name;
        $new5 = 'pictures/100x60/'.$uploader_response[0]->name;
     
        $this->image_moo->load($file_uploaded)->set_jpeg_quality(90)
            ->resize(350,210)->save($new1,true)
            ->resize(280,168)->save($new2,true)
            ->resize(196,118)->save($new3,true)
            ->resize(120,72)->save($new4,true)
            ->resize(100,60)->save($new5,true);
     
        return true;
    }

MarkC

MarkC
  • profile picture
  • Member

Posted 10 February 2013 - 09:12 AM

[member=MarkC] please post the sql of the table products so I can make a real life example.

 

Hello David,

 

Anything done so far? Or maybe you need more details from me?


davidoster

davidoster
  • profile picture
  • Member

Posted 10 February 2013 - 10:35 AM

[member=MarkC] These are quite enough. I have already started trying quite a few things and I want to check what the best solution is. I am trying to do it without modifing any of the core files of either of the two libraries(Grocer/Image Crud) in order for everybody to be able to upgrade the libraries without me needing to change the code I make as an example.

 

The way I do it is by extending the two libraries within the a new controller that binds the two together.

In essence I just make a PHP class that integrates the two of them!

I hope it will work out in the end.

 

But as I said before, next week expect to see some results.

 

 

Hello David,

 

Anything done so far? Or maybe you need more details from me?

 

 

I will try to make an example integrating grocery crud and image crud and I'll post the example, but this will be next week since I am busy!


MarkC

MarkC
  • profile picture
  • Member

Posted 10 February 2013 - 12:14 PM

[member=MarkC] These are quite enough. I have already started trying quite a few things and I want to check what the best solution is. I am trying to do it without modifing any of the core files of either of the two libraries(Grocer/Image Crud) in order for everybody to be able to upgrade the libraries without me needing to change the code I make as an example.

 

The way I do it is by extending the two libraries within the a new controller that binds the two together.

In essence I just make a PHP class that integrates the two of them!

I hope it will work out in the end.

 

But as I said before, next week expect to see some results.

 

Great, I hope there are dozens of people that are waiting for your answer :)


MarkC

MarkC
  • profile picture
  • Member

Posted 13 February 2013 - 08:24 AM

[member=MarkC] These are quite enough. I have already started trying quite a few things and I want to check what the best solution is. I am trying to do it without modifing any of the core files of either of the two libraries(Grocer/Image Crud) in order for everybody to be able to upgrade the libraries without me needing to change the code I make as an example.

 

The way I do it is by extending the two libraries within the a new controller that binds the two together.

In essence I just make a PHP class that integrates the two of them!

I hope it will work out in the end.

 

But as I said before, next week expect to see some results.

David, is there anything new? :)


davidoster

davidoster
  • profile picture
  • Member

Posted 13 February 2013 - 10:47 AM

[member=MarkC] there is some progress, check it out here: http://eletter.gr/samples/gc_ic2/index.php/gc_examples/example1_gc

but still long way from complete.


MarkC

MarkC
  • profile picture
  • Member

Posted 13 February 2013 - 11:17 AM

I can't get the idea how this will work from this example :) It still won't be in the same form where I'm entering the other product details?

 

I've got another idea, how can I implement some other jQuery Ajax uploader which uploads the images without sending the form, and somehow the image names to be stored in hidden inputs... I don't know if you understand me what I think :)