Esempio n. 1
0
File: user.go Progetto: qmdx/GoCMS
//左侧导航菜单
func (c *User) Left(menu *models.Menu) revel.Result {

	title := "左侧导航--GoCMS管理系统"

	var pid string = c.Params.Get("pid")

	if len(pid) > 0 {
		Pid, err := strconv.ParseInt(pid, 10, 64)
		if err != nil {
			revel.WARN.Println(err)
		}

		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)

			//获取左侧导航菜单
			left_menu := menu.GetLeftMenuHtml(Pid, admin_info)

			c.Render(title, left_menu)
		} else {
			c.Render(title)
		}
	} else {
		//获取左侧导航菜单
		//默认获取 我的面板
		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)

			//获取左侧导航菜单
			left_menu := menu.GetLeftMenuHtml(1, admin_info)

			c.Render(title, left_menu)
		} else {
			c.Render(title)
		}
	}
	return c.RenderTemplate("Public/left.html")
}