本帖最后由 ykjzg 于 2009-1-20 09:23 编辑
建立模型后,默认的排序方法是按发布时间,而且排序方式选择也是固定的。为了增加灵活性,本人对程序进行了以下修改:
1、修改supesite目录下的 m.php 文件
//引用自定义条件
if(empty($modelsinfoarr['tpl'])) {
$tpldir = 'model/data/'.$modelsinfoarr['modelname'];
} else {
$tpldir = 'mthemes/'.$modelsinfoarr['tpl'];
}
include_once($tpldir.'/m.php');
if(empty($orders)){
$orders = array(
'0' => $lang['check_order'],
'1' => $lang['model_dateline_desc'],
'2' => $lang['model_dateline_asc'],
'3' => $lang['model_viewnum_desc'],
'4' => $lang['model_viewnum_asc'],
'5' => $lang['model_rates_desc'],
'6' => $lang['model_rates_asc'],
'7' => $lang['model_grade_desc'],
'8' => $lang['model_grade_asc']
);
}
if(empty($orderbyarr)){
$orderbyarr = array(
'0' => 'i.itemid DESC',
'1' => 'i.dateline DESC',
'2' => 'i.dateline ASC',
'3' => 'i.viewnum DESC',
'4' => 'i.viewnum ASC',
'5' => 'i.rates DESC',
'6' => 'i.rates ASC',
'7' => 'i.grade DESC',
'8' => 'i.grade ASC'
);
}
(其中红色是加的,绿色的是从文件最后移上来的)
在model/data的相关目录中加一文件,文件名也是m.php(也可以是其他文件名,但上述代码中要做相应的修改),代码为:
<?php
$orders = array(
'0' => $lang['check_order'],
'1' => $lang['model_dateline_desc'],
'2' => $lang['model_dateline_asc'],
'3' => $lang['model_viewnum_desc'],
'4' => $lang['model_viewnum_asc'],
'5' => $lang['model_rates_desc'],
'6' => $lang['model_rates_asc'],
'7' => $lang['model_grade_desc'],
'8' => $lang['model_grade_asc'],
'9' => '按活动开始时间'
);
$orderbyarr = array(
'0' => 'i.itemid DESC',
'1' => 'i.dateline DESC',
'2' => 'i.dateline ASC',
'3' => 'i.viewnum DESC',
'4' => 'i.viewnum ASC',
'5' => 'i.rates DESC',
'6' => 'i.rates ASC',
'7' => 'i.grade DESC',
'8' => 'i.grade ASC',
'9' => 'i.datetime DESC'
);
?>
(其中绿色的为按其排序的字段名)
效果:
官方也可以考虑增加这样的功能 |