示例#1
0
//修改文章栏目页面
func (c *CategoryController) Edit() {
	CheckAdminLogin(&c.Controller, 0)
	myid := c.Ctx.Input.Param(":id")
	id, err := strconv.ParseInt(myid, 10, 64)
	if err != nil {
		EchoErrorPage(&c.Controller, "错误参数传递!", "/admin/category")
	}
	entity := models.GetCategory(id)
	if entity == nil {
		EchoErrorPage(&c.Controller, "系统找不到本记录!", "/admin/category")
	}
	//获取所有上级栏目
	PCategories := models.GetCategoryTree(0, -1, true, entity.Id)
	//获取模板目录
	skin := "default"
	templatesList, err := common.GetFolderFiles("views/"+skin, "")
	if err != nil {
		templatesList = nil
	}
	c.Data["Title"] = "修改栏目"
	c.Data["Entity"] = entity
	c.Data["Action"] = "edit"
	c.Data["TemplatesList"] = templatesList
	c.Data["PCategories"] = PCategories
	c.TplNames = "admin/category_add.tpl"
}
示例#2
0
//显示添加文章栏目
func (c *CategoryController) Add() {
	CheckAdminLogin(&c.Controller, 0)
	//添加的时候,先初始化一个实体
	entity := &models.Category{}
	entity.Id = 0
	entity.PageSize = 15
	entity.Rank = 0
	entity.DetailTemplateFile = "article.tpl"
	entity.TemplateFile = "list_article.tpl"
	//获取所有上级栏目
	PCategories := models.GetCategoryTree(0, -1, true, 0)
	//获取模板目录
	skin := "default"
	templatesList, err := common.GetFolderFiles("views/"+skin, "")
	if err != nil {
		templatesList = nil
	}
	c.Data["Title"] = "添加栏目"
	c.Data["Action"] = "add"
	c.Data["Entity"] = entity
	c.Data["TemplatesList"] = templatesList
	c.Data["PCategories"] = PCategories
	c.TplNames = "admin/category_add.tpl"
}