How would i properly sort output of a MVClister?
<?php
class page_index extends Page {
function init(){
parent::init();
$p=$this;
$this->add('MVCLi开发者_如何学编程ster',null,'News','News')->setModel('News');
$this->add('MVCLister',null,'Links','Links')->setModel('Links');
}
function defaultTemplate(){
return array('page/home'); // separate pages from views to avoid mess in templates
}
}
You can order either through model or by using lister's dq property. Model ordering would be a more global decision such as News probably should be ordered within the model:
// class Model_News, inside init() function
$this->setOrder(null, 'id', true);
If it is a user-interface condition, such as a link passed through GET, then you should apply order directly on MVCLister:
$list = $this->add('MVCLister');
$list->setModel('Links');
$list->dq->order('popularity desc');
精彩评论