Esempio n. 1
0
func BlogWithTag(ctx *middleware.Context, params martini.Params) {
	tagName := params["tag"]
	blog := new(model.Blog)
	blog.SetPageActive(true)
	blog.SetPageSize(10)
	pageNo := ParseInt(ctx.R.FormValue("page"))
	blog.SetPageNo(pageNo)
	blog.State = "PUBLISHED"
	blog.AddSortProperty("publish_date", "desc")
	blogList, total, err := blog.SearchWithTagByPage(tagName)
	PanicIf(err)
	ctx.Set("Tag", tagName)

	blog.SetTotalRecord(total)
	blog.Result = blogList
	ctx.Set("Blog", blog)
	tags, err := blog.GetAllTags()
	PanicIf(err)
	ctx.Set("Tags", tags)

	ctx.HTML(200, "blog", ctx)
}