⚠ 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

Relational N to N Custom



André Melo

André Melo
  • profile picture
  • Member

Posted 14 May 2014 - 22:10 PM

Hello, everybody. 
 
I am developing a simple website using CI + GroceryCrud, and have the following tables: 
 
tbl_site_pages
--------------------
id_page
title
 
tbl_site_images
--------------------
id_image
title
url
 
tbl_site_page_images
---------------------
id
id_page
id_image
 

 

Using the set_relation_n_n Grocery Crud, works perfectly, but as the aim here is to select images, nothing better than having a visual indication. 
 
I am developer of Python, and Django framework, it has a very interesting feature, which is using jquery to generate fields that will be saved in the intermediate table (in my case tbl_site_pages_images). 
 
This is a print of how it renders this type of relationship.
 
Ie, it generates a thumbnail shows a "magnifying glass" to open a pop to the picture list, and clicking on the desired image, it closes the pop and adds the ID of the image in the input field. 
 
I do not know how to do this in Grocery Crud. Does anyone have idea how to do, and if you can do this? 
 
Thanks for listening! (Sorry, im not speak english)

voghDev

voghDev
  • profile picture
  • Member

Posted 20 May 2014 - 09:20 AM

My case is similar to yours. I have a table 'Museums' and each museum has N 'Categories', a category can be related to N museums.

 

This tutorial helped me a lot:

 

 

http://www.grocerycrud.com/documentation/options_functions/set_relation_n_n

 

 

Just one thing that is not clear on the tutorial, the field marked as (7) is the order criteria. (maybe priority is not clear enough, the author should give a better example or add a little more explaination on this, but except for that, it worked like a charm :) )

 

Hope it helps to you too