-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
Hi,
Hope you are all well !
I would like to create a small cms and creating blocks of html content like medium.com. For doing that I need to use the rich editor for the sub-blocks in the admin form.

How can I apply the rich_editor meta to additional blocks like in the screenshot ?
Please find below my test code.
package main
import (
"fmt"
"net/http"
"github.com/jinzhu/gorm"
_ "github.com/mattn/go-sqlite3"
"github.com/qor/admin"
"github.com/qor/media/media_library"
"github.com/qor/publish2"
qor_seo "github.com/qor/seo"
"github.com/qor/slug"
)
type User struct {
gorm.Model
Username string
Email string
Disabled bool
}
type Page struct {
gorm.Model
User User
UserID uint
Title string `gorm:"type:mediumtext; CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" sql:"type:mediumtext"`
Content string `gorm:"type:longtext; CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" sql:"type:longtext"`
TitleWithSlug slug.Slug
Blocks []Block
Media media_library.MediaLibrary
publish2.Version
publish2.Schedule
publish2.Visible
Seo qor_seo.Setting
}
type Block struct {
gorm.Model
PageID uint
Title string `gorm:"type:mediumtext; CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" sql:"type:mediumtext"`
Description string `gorm:"type:longtext; CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci" sql:"type:longtext"`
Media media_library.MediaLibrary
}
func main() {
DB, _ := gorm.Open("sqlite3", "cms.db")
DB.AutoMigrate(&User{})
DB.AutoMigrate(&Page{})
DB.AutoMigrate(&Block{})
// Initialize
Admin := admin.New(&admin.AdminConfig{DB: DB})
// Allow to use Admin to manage User, Product
Admin.AddResource(&User{})
page := Admin.AddResource(&Page{})
page.Meta(&admin.Meta{
Name: "Content",
Type: "rich_editor",
})
// initalize an HTTP request multiplexer
mux := http.NewServeMux()
// Mount admin interface to mux
Admin.MountTo("/admin", mux)
fmt.Println("Listening on: 9000")
http.ListenAndServe(":9000", mux)
}Thanks in advance for your help and insights about that.
Cheers,
X
Metadata
Metadata
Assignees
Labels
No labels