|
@@ -49,10 +49,11 @@ func NewCollection() *Collection {
|
|
// @snippet_begin(SeoCollectionDefinition)
|
|
// @snippet_begin(SeoCollectionDefinition)
|
|
type Collection struct {
|
|
type Collection struct {
|
|
registeredSEO []*SEO
|
|
registeredSEO []*SEO
|
|
- globalName string //default name is GlobalSEO
|
|
|
|
- inherited bool //default is true. the order is model seo setting, system seo setting, global seo setting
|
|
|
|
- dbContextKey interface{} // get db from context
|
|
|
|
- settingModel interface{} // db model
|
|
|
|
|
|
+ globalName string //default name is GlobalSEO
|
|
|
|
+ inherited bool //default is true. the order is model seo setting, system seo setting, global seo setting
|
|
|
|
+ dbContextKey interface{} // get db from context
|
|
|
|
+ settingModel interface{} // db model
|
|
|
|
+ afterSave func(ctx context.Context, settingName string, locale string) error // hook called after saving
|
|
}
|
|
}
|
|
|
|
|
|
// @snippet_end
|
|
// @snippet_end
|
|
@@ -203,6 +204,12 @@ func (collection *Collection) GetSEOByModel(model interface{}) *SEO {
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+// AfterSave set the hook called after saving
|
|
|
|
+func (collection *Collection) AfterSave(v func(ctx context.Context, settingName string, locale string) error) *Collection {
|
|
|
|
+ collection.afterSave = v
|
|
|
|
+ return collection
|
|
|
|
+}
|
|
|
|
+
|
|
// RenderGlobal render global seo
|
|
// RenderGlobal render global seo
|
|
func (collection Collection) RenderGlobal(req *http.Request) h.HTMLComponent {
|
|
func (collection Collection) RenderGlobal(req *http.Request) h.HTMLComponent {
|
|
return collection.Render(collection.globalName, req)
|
|
return collection.Render(collection.globalName, req)
|