//blog分页显示 func (this *MainController) BlogList() { var list []*models.Post query := new(models.Post).Query().Filter("status", 0).Filter("urltype", 0) count, _ := query.Count() if count > 0 { query.OrderBy("-istop", "-posttime").Limit(this.pagesize, (this.page-1)*this.pagesize).All(&list) } this.Data["list"] = list this.Data["pagebar"] = models.NewPager(int64(this.page), int64(count), int64(this.pagesize), "/life/%d").ToString() this.setHeadMetas("点点滴滴") this.right = "right.html" this.display("life") }
//首页, 只显示前N条 func (this *MainController) Index() { var list []*models.Post query := new(models.Post).Query().Filter("status", 0).Filter("urltype", 0) count, _ := query.Count() if count > 0 { query.OrderBy("-istop", "-views").Limit(this.pagesize, (this.page-1)*this.pagesize).All(&list) } this.Data["list"] = list this.Data["pagebar"] = models.NewPager(int64(this.page), int64(count), int64(this.pagesize), "/index/%d").ToString() this.setHeadMetas() this.display("index") }