本文整理匯總了Golang中github.com/blackmady/NoneCMS/app/models.Category.Setting方法的典型用法代碼示例。如果您正苦於以下問題:Golang Category.Setting方法的具體用法?Golang Category.Setting怎麽用?Golang Category.Setting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/blackmady/NoneCMS/app/models.Category
的用法示例。
在下文中一共展示了Category.Setting方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Add
//.........這裏部分代碼省略.........
}
var enname string = c.Params.Get("enname")
if len(enname) > 0 {
category.Enname = enname
} else {
c.Flash.Error("請輸入英文欄目名稱!")
c.Flash.Out["url"] = "/Category/Add/"
return c.Redirect("/Message/")
}
//欄目地址
var url string = c.Params.Get("url")
if len(url) > 0 {
category.Url = url
} else {
c.Flash.Error("請輸入欄目地址!")
c.Flash.Out["url"] = "/Category/Add/"
return c.Redirect("/Message/")
}
//描述
var desc string = c.Params.Get("desc")
if len(desc) > 0 {
category.Desc = desc
} else {
c.Flash.Error("請輸入描述!")
c.Flash.Out["url"] = "/Category/Add/"
return c.Redirect("/Message/")
}
//是否在導航顯示
var ismenu string = c.Params.Get("ismenu")
if len(ismenu) > 0 {
IsMenu, err := strconv.ParseInt(ismenu, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
category.Ismenu = IsMenu
} else {
c.Flash.Error("請選擇是否在導航顯示!")
c.Flash.Out["url"] = "/Category/Add/"
return c.Redirect("/Message/")
}
Setting := make(map[string]interface{})
//欄目生成Html
var ishtml string = c.Params.Get("ishtml")
Setting["ishtml"] = ishtml
var content_ishtml string = c.Params.Get("content_ishtml")
Setting["content_ishtml"] = content_ishtml
var meta_title string = c.Params.Get("meta_title")
Setting["meta_title"] = meta_title
var meta_keywords string = c.Params.Get("meta_keywords")
Setting["meta_keywords"] = meta_keywords
var meta_desc string = c.Params.Get("meta_desc")
Setting["meta_desc"] = meta_desc
//欄目設置
Setting_Text, err := json.Marshal(Setting)
if err != nil {
revel.WARN.Println(err)
}
category.SettingText = Setting
category.Setting = string(Setting_Text)
if category.Save() {
//******************************************
//管理員日誌
if UserID, ok := c.Session["UserID"]; ok {
UserID, err := strconv.ParseInt(UserID, 10, 64)
if err != nil {
revel.WARN.Println(err)
}
admin := new(models.Admin)
admin_info := admin.GetById(UserID)
logs := new(models.Logs)
desc := "添加欄目:" + name + "|^|欄目管理"
logs.Save(admin_info, c.Controller, desc)
}
//*****************************************
c.Flash.Success("添加欄目成功")
c.Flash.Out["url"] = "/Category/"
return c.Redirect("/Message/")
} else {
c.Flash.Error("添加欄目失敗")
c.Flash.Out["url"] = "/Category/Add/"
return c.Redirect("/Message/")
}
}
}