⚠ 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

Image crud set relation field



Izzu James

Izzu James
  • profile picture
  • Member

Posted 18 August 2013 - 20:20 PM

how do you set relation field and how does it know which table the relation field comes from

 

       $crud = new image_CRUD();        
        $crud->set_primary_key_field('ImageId');
        $crud->set_url_field('ImageUrl');
        $crud->set_table('fimages');
        $crud->set_title_field('ImageTitle');
        $crud->set_relation_field('category_Id');
        $crud->set_ordering_field('ImagePriority');
        $crud->set_image_path('assets/uploads/files/gallery');            
        $output = $crud->render();
          $v='index';        
        $this->_module_output($output,$v);

 

 

the above code is not working

 

but if i remove the $crud->set_relation_field('category_Id');  its working please give me a solution i need to arrange images according to categories

 

 

 


Izzu James

Izzu James
  • profile picture
  • Member

Posted 20 August 2013 - 16:47 PM

No one has the solution ? 33 views no reply :(


chavamm

chavamm
  • profile picture
  • Member

Posted 20 August 2013 - 17:03 PM

Hi,
could you please have a little patience?

I hope help you.

       $crud = new image_CRUD();        
        $crud->set_primary_key_field('ImageId');
        $crud->set_url_field('ImageUrl');
        $crud->set_table('fimages');
        $crud->set_title_field('ImageTitle');

        //Note that the correct method name is $crud->set_relation() and NOT $crud->set_relation_field()
        $crud->set_relation('category_Id', 'category_dbtable', 'field_display_on_dbtable'); 

        $crud->set_ordering_field('ImagePriority');
        $crud->set_image_path('assets/uploads/files/gallery');            
        $output = $crud->render();
        
        $v='index';        
        $this->_module_output($output,$v);


Please, read the gc documentation: http://www.grocerycrud.com/documentation/options_functions/set_relation

Thanks, Regards.


Izzu James

Izzu James
  • profile picture
  • Member

Posted 20 August 2013 - 17:22 PM

sorry but i dint understand set_relation is a method of grocery crud it is not working woth image crud


chavamm

chavamm
  • profile picture
  • Member

Posted 20 August 2013 - 18:56 PM

sorry but i dint understand set_relation is a method of grocery crud it is not working woth image crud

Hi, you have reason, I'm Sorry, i don't read that is about Image Crud.

 

The category_id param is send by url in 3rd segment, ex.

 

 index.php/images_examples/example3/23

 

In this example the category_id in the db table is set to 23.

// Your table should have a field 'category_id',  if no exists, could be the error cause
$crud->set_relation_field('category_Id'); 

Thanks, regards!


Izzu James

Izzu James
  • profile picture
  • Member

Posted 20 August 2013 - 19:14 PM

Thanks a lot this solves my problem :)


Carlos Avalos

Carlos Avalos
  • profile picture
  • Member

Posted 30 September 2013 - 14:22 PM

I have same problem, please, can you post the solution here, thanks.


davidoster

davidoster
  • profile picture
  • Member

Posted 30 September 2013 - 15:48 PM

Hello and welcome to the forums [member=carlos avalos].

Image Crud contains an images_examples.php controller (under application/controllers).

If you check the code on example 3 (which is the same with the documentation) it has

set_relation_field('category_id')

and if you check on the database table example_3 it contains 3 records where the category_id has a value of 22.

This means that they are on the same category so they are grouped together. It is as simple as that.


HPM

HPM
  • profile picture
  • Member

Posted 11 June 2015 - 05:45 AM

hello! so how can we add another category to the table?for a example lets say i want to add 23 under category field.i have try the image crud example and i can see the pictures are under category 22,but how can we insert another category id like 23,?please explain,thank you


sid

sid
  • profile picture
  • Member

Posted 12 June 2015 - 16:15 PM

Hi, you have reason, I'm Sorry, i don't read that is about Image Crud.

 

The category_id param is send by url in 3rd segment, ex.

 

 index.php/images_examples/example3/23

 

In this example the category_id in the db table is set to 23.

// Your table should have a field 'category_id',  if no exists, could be the error cause
$crud->set_relation_field('category_Id'); 

Thanks, regards!

hello ! i cant understand this part of your explanation,"The category_id param is send by url in 3rd segment" could you please explain it?i still can get how to store multiple images under a unique category:(