function sp_sql_qiushis_paged($tag = "", $pagesize = 20, $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}') { $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : 'b.*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'createtime desc'; $field = "a.cat_name,c.user_login,c.user_nicename," . $field; $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.status" => 1, "a.status" => 1); if (isset($tag['cid'])) { $where['cid'] = array('in', $tag['cid']); } $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushis = $qiushi_cat_model->field($field)->alias("a")->join($join)->join($join2)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $return['count'] = $totalsize; $return['items'] = $qiushis; $return['page'] = $page->show('default'); return $return; }
/** * 4 * @ 处理标签函数 * @ $tag以字符串方式传入,通过sp_param_lable函数解析为以下变量。例:"cid:1,2;order:post_date desc,listorder desc;" * ids:调用指定id的一个或多个数据,如 1,2,3 * cid:数据所在分类,可调出一个或多个分类数据,如 1,2,3 默认值为全部,在当前分类为:'.$cid.' * field:调用post指定字段,如(id,post_title...) 默认全部 * limit:数据条数,默认值为10,可以指定从第几条开始,如3,8(表示共调用8条,从第3条开始) * order:推荐方式(post_date) (desc/asc/rand()) */ function sp_sql_posts_paged($tag, $pagesize = 20, $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}') { $where = array(); $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : '*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'post_date'; //根据参数生成查询条件 $where['status'] = array('eq', 1); $where['post_status'] = array('eq', 1); if (isset($tag['cid'])) { $where['term_id'] = array('in', $tag['cid']); } if (isset($tag['ids'])) { $where['object_id'] = array('in', $tag['ids']); } $join = "" . C('DB_PREFIX') . 'posts as b on a.object_id =b.id'; $join2 = "" . C('DB_PREFIX') . 'users as c on b.post_author = c.id'; $rs = M("PtermRelationships"); $totalsize = $rs->alias("a")->join($join)->join($join2)->field($field)->where($where)->count(); import('Page'); if ($pagesize == 0) { $pagesize = 20; } $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $posts = $rs->alias("a")->join($join)->join($join2)->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $content['posts'] = $posts; $content['page'] = $page->show('default'); return $content; }
public function index() { $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.status" => 1, "a.status" => 1); $catid = I("get.cat", 0, "intval"); if (!empty($catid)) { $where['a.id'] = $catid; } $order = array("b.istop" => "desc"); $sort = I("get.sort", 0, "intval"); if (empty($sort)) { $order['b.createtime'] = "desc"; } else { $sort == 1 ? $order['b.last_comment'] = "desc" : ""; //按最新回复 if ($sort == 2) { //精华 $where['b.star'] = array("gt", 0); $order['b.createtime'] = "desc"; } } $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, 15); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushis = $qiushi_cat_model->field("a.cat_name,b.*,c.user_login,c.user_nicename")->alias("a")->join($join)->join($join2)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("pager", $page->show('default')); $qiushi_cats = $qiushi_cat_model->where(array("status" => 1))->order("listorder asc")->select(); $this->assign("qiushi_cats", $qiushi_cats); $catid = I("get.cat", 0, "intval"); if (!empty($catid)) { $qiushi_cat = $qiushi_cat_model->where(array("id" => $catid))->find(); $this->assign("qiushi_cat", $qiushi_cat); } $this->assign("qiushis", $qiushis); $this->display(":index"); }
public function index() { $qiushi_cat_model = M("QiushiCat"); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $where = array("b.uid" => get_current_userid()); $totalsize = $qiushi_cat_model->alias("a")->join($join)->where($where)->count(); import('Page'); $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, 10); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}'; $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $qiushi_cats = $qiushi_cat_model->where(array("status" => 1))->select(); $this->assign("qiushi_cats", $qiushi_cats); $join = C('DB_PREFIX') . 'qiushi as b on a.id =b.cid'; $join2 = C('DB_PREFIX') . 'users as c on c.id =b.uid'; $qiushis = $qiushi_cat_model->field("a.cat_name,b.*,c.user_login,c.user_nicename")->alias("a")->join($join)->join($join2)->where($where)->order("b.createtime desc")->limit($page->firstRow . ',' . $page->listRows)->select(); $this->assign("pager", $page->show('default')); $this->assign("qiushis", $qiushis); $this->display(); }
function sp_content_page($content, $pagetpl = '{first}{prev}{liststart}{list}{listend}{next}{last}') { $contents = explode('_ueditor_page_break_tag_', $content); $totalsize = count($contents); import('Page'); $pagesize = 1; $PageParam = C("VAR_PAGE"); $page = new \Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->SetPager('default', $pagetpl, array("listlong" => "6", "first" => "首页", "last" => "尾页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $content = $contents[$page->firstRow]; $data['content'] = $content; $data['page'] = $page->show('default'); return $data; }
/** * 商品列表,带page * @ 处理标签函数 * @ $tag以字符串方式传入,通过sp_param_lable函数解析为以下变量。例:"order:add_time desc,update_time desc;" * ids:调用指定id的一个或多个数据,如 1,2,3 * field:调用goods指定字段,如(goods_id,goods_name...) 默认全部 * limit:数据条数,默认值为10,可以指定从第几条开始,如3,8(表示共调用8条,从第3条开始) * order:推荐方式(add_time) (desc/asc/rand()) */ function sp_sql_goods_paged($tag, $pagesize = 20) { $where = array(); $tag = sp_param_lable($tag); $field = !empty($tag['field']) ? $tag['field'] : '*'; $limit = !empty($tag['limit']) ? $tag['limit'] : ''; $order = !empty($tag['order']) ? $tag['order'] : 'add_time'; //根据参数生成查询条件 $where['goods_state'] = array('eq', 1); if (isset($tag['cid'])) { $where['term_id'] = array('in', $tag['cid']); } if (isset($tag['keywords'])) { $where['goods_name'] = array('like', "%" . $tag['keywords'] . "%"); } if (isset($tag['ids'])) { $where['goods_id'] = array('in', $tag['ids']); } $goods = D("Goods"); $totalsize = $goods->field($field)->where($where)->count(); import('Page'); if ($pagesize == 0) { $pagesize = 20; } $PageParam = C("VAR_PAGE"); $page = new Page($totalsize, $pagesize); $page->setLinkWraper("li"); $page->__set("PageParam", $PageParam); $page->SetPager('default', '<div class="page">{prev} {list} {listend} {next}</div>', array("listlong" => "6", "first" => "首页", "prev" => "上一页", "next" => "下一页", "list" => "*", "disabledclass" => "")); $list = $goods->field($field)->where($where)->order($order)->limit($page->firstRow . ',' . $page->listRows)->select(); $content['goods'] = $list; $content['count'] = $totalsize; $content['page'] = $page->show('default'); return $content; }