查看包含标签的文档列表.
()
| 26 | |
| 27 | // 查看包含标签的文档列表. |
| 28 | func (this *LabelController) Index() { |
| 29 | this.TplName = "label/index.html" |
| 30 | this.Data["IsLabel"] = true |
| 31 | |
| 32 | labelName := this.Ctx.Input.Param(":key") |
| 33 | |
| 34 | this.Redirect(beego.URLFor("SearchController.Result")+"?wd="+labelName, 302) |
| 35 | return |
| 36 | |
| 37 | this.Data["Keyword"] = labelName |
| 38 | pageIndex, _ := this.GetInt("page", 1) |
| 39 | if labelName == "" { |
| 40 | this.Abort("404") |
| 41 | } |
| 42 | pageSize := 24 |
| 43 | memberId := 0 |
| 44 | if this.Member != nil { |
| 45 | memberId = this.Member.MemberId |
| 46 | } |
| 47 | searchResult, totalCount, err := models.NewBook().FindForLabelToPager(labelName, pageIndex, pageSize, memberId) |
| 48 | if err != nil { |
| 49 | beego.Error(err) |
| 50 | return |
| 51 | } |
| 52 | |
| 53 | if totalCount > 0 { |
| 54 | html := utils.NewPaginations(conf.RollPage, totalCount, pageSize, pageIndex, beego.URLFor("LabelController.Index", ":key", labelName), "") |
| 55 | this.Data["PageHtml"] = html |
| 56 | } else { |
| 57 | this.Data["PageHtml"] = "" |
| 58 | } |
| 59 | this.Data["Lists"] = searchResult |
| 60 | this.Data["LabelName"] = labelName |
| 61 | this.GetSeoByPage("label_list", map[string]string{ |
| 62 | "title": "[标签]" + labelName, |
| 63 | "keywords": "标签," + labelName, |
| 64 | "description": this.Sitename + "专注于文档在线写作、协作、分享、阅读与托管,让每个人更方便地发布、分享和获得知识。", |
| 65 | }) |
| 66 | } |
| 67 | |
| 68 | // 标签列表 |
| 69 | func (this *LabelController) List() { |
nothing calls this directly
no test coverage detected