hi, i trying rewrite the code to obtain threaded results of Image model in
the first request. How can I do?
$this->paginate = array(
'conditions' => array('Product.company_id' =>
$user_logged['User']['company_id'],'Product.deleted'=>0,'Product.status'=>1),
'limit' => 4,
'order' => array('Product.created DESC'),
'contain' => array(
'Image'=>array(
*'findType'=>'threaded'*
)
)
);
$products = $this->paginate('Product');
*Currently this is the code I use to get the expected result:
*
public function published(){
$user_logged = $this->Auth->User();
$this->paginate = array(
'conditions' => array('Product.company_id' =>
$user_logged['User']['company_id'],'Product.deleted'=>0,'Product.status'=>1),
'limit' => 4,
'order' => array('Product.created DESC'),
'contain' => array(
'Image'=>array(
)
)
);
$products = $this->paginate('Product');
$this->loadModel('Image');
foreach($products as $index_0 =>$product){
$data[$index_0]['product'] = $product['Product'];
foreach($product['Image'] as $index_1 => $original_imagen){
$data[$index_0]['imagen']['original'] = $original_imagen;
$products[$index_0]['Image']['childrens'] = *
$this->Image->find('all',array(*
* 'conditions' => array('Image.parent_id' => $original_imagen['id']),*
* 'contain' => false *
* )*
);
foreach($products[$index_0]['Image']['childrens'] as $index_2 => $children
){
switch ($children['Image']['size']) {
case '1920x1080':
$namespace = 'large';
break;
case '900x900':
$namespace = 'median';
break;
case '400x400px':
$namespace = 'small';
break;
}
$data[$index_0]['imagen']['thumbnails'][$namespace] = $children['Image'];
}
}
}
/*
// *result:*
*$data = array(*
* 'product'=>*
* 'imagen'=>array(*
* 'original'=>*
* 'thumbnails'=>array(*
* 'large'=>,*
* 'median'=>,*
* 'small'=>,*
* )*
* )*
* )*
*/
$this->set('products',$data);
}
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.