當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Wrapper.SetContent方法代碼示例

本文整理匯總了Golang中github.com/mongolar/mongolar/wrapper.Wrapper.SetContent方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.SetContent方法的具體用法?Golang Wrapper.SetContent怎麽用?Golang Wrapper.SetContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/mongolar/mongolar/wrapper.Wrapper的用法示例。


在下文中一共展示了Wrapper.SetContent方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: WrapperValues

// The controller function for Values found directly in the controller values of the element
func WrapperValues(w *wrapper.Wrapper) {
	var wrapid string
	if len(w.APIParams) > 0 {
		wrapid = w.APIParams[0]
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return
	}
	e, err := elements.LoadWrapperElement(wrapid, w)
	if err != nil {
		errmessage := fmt.Sprintf("Content not found %s : %s", wrapid, err.Error())
		w.SiteConfig.Logger.Error(errmessage)
		services.AddMessage("There was a problem loading some content on your page.", "Error", w)
		w.Serve()
		return
	}
	var v []elements.Element
	for _, id := range e.Elements {
		e := elements.NewElement()
		err = elements.GetById(id, &e, w)
		if err != nil {
			errmessage := fmt.Sprintf("Content not found %s : %s", id, err.Error())
			w.SiteConfig.Logger.Error(errmessage)
		} else {
			v = append(v, e)
		}
	}
	w.SetDynamicId(e.DynamicId)
	w.SetContent(v)
	w.Serve()
}
開發者ID:ultimatums,項目名稱:mongolar,代碼行數:33,代碼來源:wrapper.go

示例2: AdminPaths

// Controller to list all paths
func AdminPaths(w *wrapper.Wrapper) {
	pl, err := paths.PathList(w)
	if err != nil {
		services.AddMessage("There was an error retrieving your site paths", "Error", w)
		errmessage := fmt.Sprintf("Error getting path list: %s", err.Error())
		w.SiteConfig.Logger.Error(errmessage)
	} else {
		w.SetContent(pl)
	}
	w.Serve()
}
開發者ID:bdatchar,項目名稱:mongolar,代碼行數:12,代碼來源:path.go

示例3: PathValues

// The controller function to retrieve elements ids from the path
func PathValues(w *wrapper.Wrapper) {
	// Request is never url based so we can Never cache this request.
	// TODO: move no caching into a reusable function.
	w.Writer.Header().Add("Cache-Control", "no-cache, no-store, must-revalidate")
	w.Writer.Header().Add("Pragma", "no-cache")
	w.Writer.Header().Add("Expires", "0")
	p := paths.NewPath()
	u := w.Request.Header.Get("CurrentPath")
	if u == "" {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return
	}
	qp, err := p.PathMatch(u, "published", w)
	if err != nil {
		if err.Error() == "not found" {
			if "/"+w.SiteConfig.FourOFour != u {
				services.Redirect("/"+w.SiteConfig.FourOFour, w)
				w.Serve()
				return
			} else {
				services.AddMessage("There was a problem with the system.", "Error", w)
				w.Serve()
				return
			}

		}

	}
	var v []elements.Element
	for _, eid := range p.Elements {
		e := elements.NewElement()
		err = elements.GetById(eid, &e, w)
		if err != nil {
			errmessage := fmt.Sprintf("Content not found %s : %s", eid, err.Error())
			w.SiteConfig.Logger.Error(errmessage)
		} else {
			v = append(v, e)
		}
	}
	w.SetPayload("mongolar_slug", qp)
	w.SetContent(v)
	w.SetTemplate(p.Template)
	w.Serve()
	return
}
開發者ID:bdatchar,項目名稱:mongolar,代碼行數:47,代碼來源:paths.go

示例4: ContentValues

// The controller function for Values found directly in the controller values of the element
func ContentValues(w *wrapper.Wrapper) {
	var contentid string
	if len(w.APIParams) > 0 {
		contentid = w.APIParams[0]
	} else {
		http.Error(w.Writer, "Forbidden", 403)
		w.Serve()
		return

	}
	e, err := elements.LoadContentElement(contentid, w)
	if err != nil {
		errmessage := fmt.Sprintf("Content not found %s : %s", contentid, err.Error())
		w.SiteConfig.Logger.Error(errmessage)
		services.AddMessage("There was a problem loading some content on your page.", "Error", w)
		w.Serve()
		return
	}
	w.SetContent(e.ContentValues.Content)
	w.Serve()
	return
}
開發者ID:bdatchar,項目名稱:mongolar,代碼行數:23,代碼來源:content.go

示例5: AdminMenu

// Structure of url links that appear on the admin page.
func (a *AdminMenu) AdminMenu(w *wrapper.Wrapper) {
	w.SetContent(a)
	w.Serve()
	return
}
開發者ID:bdatchar,項目名稱:mongolar,代碼行數:6,代碼來源:admin.go


注:本文中的github.com/mongolar/mongolar/wrapper.Wrapper.SetContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。