Bỏ qua, đến nội dung

Cấu hình

Database

Bảng blockTemplates

CộtKiểuMô tả
keystring (PK)Khóa duy nhất của template
titlestringTên hiển thị
descriptiontextMô tả template
typestringLoại block: form, details, table, ...
collectionstringCollection liên kết
dataSourcestringData source
componentTypestringLoại component
menuNamestringTên menu chứa template
configuredbooleanĐã cấu hình xong chưa

Quan hệ: belongsTo uiSchema — template trỏ đến schema đã lưu trong plugin-ui-schema-storage.

CộtKiểuMô tả
iduid (PK)Định danh
templateKeystring (FK)Trỏ đến blockTemplates.key
uiSchemaUidstring (FK)Trỏ đến uiSchema đang dùng template

Mỗi bản ghi trong bảng này đại diện một block đang sử dụng template ở chế độ inherited.

Template kế thừa (Inherited)

Khi block sử dụng template inherited:

  1. Server clone uiSchema gốc cho block mới.
  2. Tạo bản ghi blockTemplateLinks liên kết block ↔ template.
  3. Khi template thay đổi → middleware templateDataMiddleware inject dữ liệu template mới.
  4. Block tự cập nhật theo template gốc.

Ngắt liên kết

Chọn Convert to normal block trong designer → xóa bản ghi link, block trở thành độc lập.

API endpoints

EndpointMethodMô tảACL
blockTemplates:listGETLiệt kê templateloggedIn
blockTemplates:getGETChi tiết templateloggedIn
blockTemplates:saveSchemaPOSTLưu block schema thành templateloggedIn
blockTemplates:linkPOSTLiên kết block với templateloggedIn
blockTemplates:destroyDELETEXóa templateloggedIn

Middleware

MiddlewareVai trò
templateDataMiddlewareInject dữ liệu template vào request context khi block sử dụng template

Hỗ trợ mobile template

Plugin tích hợp với plugin-mobile để hỗ trợ template cho layout mobile:

  • Template có thể được tạo từ block trên giao diện mobile.
  • Khi sử dụng template trên mobile, layout tự động adapt theo mobile screen.
  • Admin quản lý cả desktop và mobile template từ cùng trang Block Templates.

Decorator kế thừa

Block inherited hiển thị badge "Template" qua TemplateGridDecorator — giúp admin nhận biết block nào đang liên kết template.