本文整理匯總了Golang中github.com/mongolar/mongolar/wrapper.Wrapper.SetDynamicId方法的典型用法代碼示例。如果您正苦於以下問題:Golang Wrapper.SetDynamicId方法的具體用法?Golang Wrapper.SetDynamicId怎麽用?Golang Wrapper.SetDynamicId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mongolar/mongolar/wrapper.Wrapper
的用法示例。
在下文中一共展示了Wrapper.SetDynamicId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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()
}
示例2: Element
// Controller to render an element in content editor
func Element(w *wrapper.Wrapper) {
e := elements.NewElement()
var id string
if len(w.APIParams) == 0 {
http.Error(w.Writer, "Forbidden", 403)
return
} else {
id = w.APIParams[0]
}
err := elements.GetById(id, &e, w)
if err != nil {
errmessage := fmt.Sprintf("Element not found to edit for %s by %s.", id, w.Request.Host)
w.SiteConfig.Logger.Error(errmessage)
services.AddMessage("This element was not found", "Error", w)
} else {
w.SetPayload("mongolarid", e.MongoId.Hex())
w.SetPayload("title", e.Title)
w.SetPayload("mongolartype", e.Controller)
w.SetDynamicId(e.MongoId.Hex())
if e.Controller == "wrapper" {
we, err := elements.LoadWrapperElement(id, w)
if err != nil {
errmessage := fmt.Sprintf("Element not found to edit for %s by %s.", id, w.Request.Host)
w.SiteConfig.Logger.Error(errmessage)
services.AddMessage("This element was not found", "Error", w)
}
w.SetPayload("elements", we.Elements)
}
if e.Controller == "slug" {
we, err := elements.LoadSlugElement(id, w)
if err != nil {
errmessage := fmt.Sprintf("Element not found to edit for %s by %s.", id, w.Request.Host)
w.SiteConfig.Logger.Error(errmessage)
services.AddMessage("This element was not found", "Error", w)
}
w.SetPayload("elements", we.Slugs)
}
}
w.Serve()
}