#I have the Model Tipo class Tipo extends AppModel { var $displayField = 'nombre';
var $hasMany = array('Productos'=>array( 'className'=>'Producto', 'foreignKey'=>'id_tipo' ) ); } #and Model Producto class Producto extends AppModel { var $displayField = 'nombre'; var $belongsTo = array('Tipo'=>array( 'className'=>'Tipo', 'foreignKey'=>'id_tipo') ); } #and the controller productos_controller.php /* Iam using pagination */ class ProductosController extends AppController { var $uses = array('Producto', 'Tipo'); var $paginate = array('Producto'=>array('limit' => LIMIT), 'Tipo'=>array('limit' => LIMIT)); function index() { $productos = $this->paginate('Producto'); $this->set('productos', $productos ); } } #And my view is <table class="tabla" width="700"> <caption> <?php echo $html->link('Crear Producto', 'add/').'<br/>';?> <div class="paging"> Página <?php echo $paginator->counter(array('separator' => ' de ')); ? > <?php echo $paginator->prev('<<Ant').' '.$paginator->next('Sig>>')?> </div> </caption> <?php $tr = array($paginator->sort('ID', 'id', array('model'=>'Producto')), $paginator->sort('Nombre', 'nombre', array('model'=>'Producto')), $paginator->sort('Páginas', 'paginas', array('model'=>'Producto')), $paginator->sort('Creado', 'creado', array('model'=>'Producto')), $paginator->sort('Tipo', 'nombre', array('model'=>'Tipo')), 'Acciones'); echo $html->tableHeaders($tr); ?> <?php //echo pr($this->params); foreach($productos as $v) { $id = $v['Producto']['id_producto']; $link = '<small>'; $link.= $html->link('ver',"view/$id").' '; $link.= $html->link('editar',"edit/$id").' '; $link.= $html->link('borrar', "delete/$id",null,"Esta seguro de Borrar el ID $id"); $link.= '</small>'; $tr = array( $id, $v['Producto']['nombre'], '<div class="r">'.$v['Producto']['paginas'].'</div>', $date->dateFormat($v['Producto']['creado']), $v['Tipo']['nombre'], $link ); echo $html->tableCells($tr,null, array('class'=>'altRow') ); } ?> </table> /***************************************/ My question is how can I make to order using the Model 'Tipo' and the field nombre when I click on the header table 'Tipo' which holds the Tipo.nombre it orders the table by Producto.nombre but If I use: $paginator->sort('Tipo', 'Tipo.nombre', array('model'=>'Tipo')) it orders asc using the Tipo model but I can't make it order desc. How can I make make this happen. Thanx in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---