I was on a vacation and I just came back... I am continuing my work on project again..
Thanks Paul for your answer.
Here's where I am now:
1. I have tried to do it this way but keeping that count up to date can be quite difficult... I have tried to do it and I have ran into some problems with deleting images and updating the count... Long story short, I'd like to avoid this solution...
2. I have checked custom_model docs http://www.grocerycrud.com/documentation/options_functions/set_model and I wasn't able to figure it out... Seems like a decent solution but I just can't figure it out... Some quality samples on the topic would be nice since this looks pretty useful and I'll probably need in the future...
3. This looks like something that will work... and that's not really hard to implement. My problem is how to pass that extended data results to the column_category..
Here's what I've got:
// Adds a custom column count
$crud->columns('name', 'count');
// Callback for the custom column _callback_get_counter
$crud->callback_column('count', array($this, '_callback_get_counter'));
/* Just before the view I have this */
$this->state = $crud->getState();
if(in_array($this->state, array('list','success')))
{
$this->db->select('categories.id, (SELECT COUNT(*) FROM images i WHERE i.category = categories.id ) as img_qty', false);
$q = $this->db->get('categories');
/* Do I need anything else in here ??? */
}
// Callback function
public function _callback_get_counter($value, $row) {
return $row->img_qty';
}
But this simply doesn't work...