开发者

How would i set order of MVCLister?

开发者 https://www.devze.com 2023-04-03 13:10 出处:网络
How would i properly sort output of a MVClister? <?php class page_index extends Page { function init(){

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消