Esempio n. 1
0
func (c *TopicController) Get() {
	c.Data["IsLogin"] = checkLogin(c.Ctx)
	c.Data["IsTopic"] = true
	c.TplNames = "topic.html"

	// 获取所有文章
	// 参数:分类、标签、排序
	topics, err := models.GetAllTopics("", "", false)
	if err != nil {
		beego.Error(err)
	} else {
		c.Data["Topics"] = topics
	}
}
Esempio n. 2
0
func (c *MainController) Get() {
	c.Data["IsHome"] = true
	c.Data["IsLogin"] = checkLogin(c.Ctx)
	c.TplNames = "home.html"

	topics, err := models.GetAllTopics(c.Input().Get("cate"), c.Input().Get("label"), true)
	if err != nil {
		beego.Error(err)
	}
	c.Data["Topics"] = topics

	category, err := models.GetAllCategories()
	if err != nil {
		beego.Error(err)
	}
	c.Data["Categories"] = category
}