文章按活动周期排序
应用场景
网站发布的都是活动,活动有周期,先需要对文章进行排序,优先显示正在进行和即将进行的活动,然后再显示之前发布过的活动。
代码案例
挂接口
Add_Filter_Plugin('Filter_Plugin_LargeData_Article', 'ytecn_order_LargeData_GetList');
函数
function ytecn_order_LargeData_GetList(&$select, &$w, &$order, &$count, &$option,$type) { global $zbp; $order = array('CASE WHEN log_PostTime < UNIX_TIMESTAMP() THEN 2 ELSE 1 END, CASE WHEN log_PostTime < UNIX_TIMESTAMP() THEN UNIX_TIMESTAMP() - log_PostTime ELSE log_PostTime END'); }
扩展
根据页面判定是否生效
if($type=='category'){} if($type=='index'){}
根据分类判定是否生效
$id=$option['pagebar']->UrlRule->Rules['{%id%}'];