func (this *TopicController) View() { this.TplNames = "topic_view.html" tid := this.Ctx.Input.Params("0") topic, err := models.GetTopic(tid) if err != nil { beego.Error(err) this.Redirect("/", 302) return } this.Data["Topic"] = topic replies, err := models.GetAllReplies(tid) if err != nil { beego.Error(err) return } this.Data["Replies"] = replies this.Data["IsLogin"] = checkAccount(this.Ctx) }
func (this *TopicController) View() { this.TplNames = "topic_view.html" reqUrl := this.Ctx.Request.RequestURI i := strings.LastIndex(reqUrl, "/") tid := reqUrl[i+1:] topic, err := models.GetTopic(tid) if err != nil { beego.Error(err) this.Redirect("/", 302) return } this.Data["Topic"] = topic this.Data["Lables"] = strings.Split(topic.Lables, " ") replies, err := models.GetAllReplies(tid) if err != nil { beego.Error(err) return } this.Data["Replies"] = replies this.Data["IsLogin"] = checkAccount(this.Ctx) }