bagisto-theme-sections
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTheme Sections
主题Sections
packages/Webkul/Themesettings/themespackages/Webkul/Themesettings/themesReference files
参考文件
| File | Load when |
|---|---|
| drafts.md | The staging model — what is held, what publishing does, the preview |
| sections.md | Section types, the field schema, media, and the rules per type |
| 文件 | 加载场景 |
|---|---|
| drafts.md | 暂存模型——存储内容、发布操作、预览相关说明 |
| sections.md | Section类型、字段 schema、媒体资源及各类型规则 |
Where things live
目录结构
| Path | What |
|---|---|
| The gallery — installed themes and ones on offer |
| The editor for one theme, on one channel |
| The storefront rendered from drafts, framed in the editor |
ThemeCatalogSectionSchemaSectionRepository| 路径 | 说明 |
|---|---|
| 主题库——已安装主题及可供选择的主题 |
| 单主题单渠道的编辑器 |
| 基于草稿渲染的前台,在编辑器中展示 |
ThemeCatalogSectionSchemaSectionRepositoryNothing goes live until it is published
未发布内容不会上线
This is the rule the whole area is built on. Every change is staged —
editing content, toggling a section on or off, and dragging it to a new
position. Each is held on the row and applied only when the operator publishes:
| Change | Held in |
|---|---|
| Content, per locale | |
| On/off | |
| Order | |
A draft column is nulled when it would equal the live value, so toggling a
section off and back on leaves nothing staged rather than an empty pending
change. is true when any of the three is set, and that is what the
editor's unsaved-changes count and per-row dot read.
hasDraft()publishDraft()discardDraft()这是整个区域的核心规则。所有更改都会被暂存——编辑内容、切换Section的启用/禁用状态、拖动调整位置。这些更改都会被存储,仅当操作人员执行发布操作时才会生效:
| 更改类型 | 存储位置 |
|---|---|
| 多语言内容 | |
| 启用/禁用状态 | |
| 排序顺序 | |
当草稿字段与线上值相同时,该字段会被置空,因此切换Section禁用后再启用不会留下待处理的空更改。当上述三个字段中的任意一个被设置时, 返回true,这也是编辑器中未保存更改计数及每行标记的判断依据。
hasDraft()publishDraft()discardDraft()Non-negotiables
不可协商规则
- The storefront reads live values, the preview reads drafts. The switch is
, set in the request's internal attribute bag — never from a query parameter, or a visitor could ask a storefront page for unpublished content. Use
SectionRepository::PREVIEWINGfor the storefront andgetRenderable()for the preview; do not branch on the flag yourself.getDraftedForPreview() - The preview is admin-only. aborts unless
appearance-preview— an authenticated admin without that permission is not enough.bouncer()->hasPermission('appearance.sections') - Sanitise on the way in. HTML and CSS pass through Purify and
static_contentin the repository, on both the draft and the publish path. A new write path must go throughsanitizeStaticCss().sanitizeOptions() - One footer per channel. is a singleton, guarded server-side in the controller — not only by hiding the type in the UI.
footer_links - Clear the page cache on every change. FPC listens to ,
section.create.afterandsection.update.after;section.delete.beforeandfooter_linksare drawn by the layout on every page, so those clear the whole cache rather than just the home page.services_content - Fire before and after events. Every action dispatches a pair —
,
section.create.*,section.update.*,section.delete.*,section.draft.save.*,section.draft.discard.*,section.media.upload.*. A new action needs both, or FPC and third-party listeners miss it.section.reorder.* - Guard against a section deleted in another tab. Every action resolves
through and answers with a plain "no longer exists" rather than a 500.
sectionOrFail() - A section's media directory is removed by on delete, not by the controller.
SectionObserver
REQUIRED SUB-SKILL: Use bagisto-change-verification before calling any change done.
- 前台读取线上值,预览读取草稿值。切换标识为,通过请求的内部属性包设置——绝不能通过查询参数设置,否则访客可能获取到未发布内容。前台使用
SectionRepository::PREVIEWING,预览使用getRenderable();请勿自行根据标识进行分支判断。getDraftedForPreview() - 预览仅对管理员开放。会在
appearance-preview不满足时终止——仅登录但无该权限的管理员无法访问。bouncer()->hasPermission('appearance.sections') - 输入时进行内容清理。中的HTML和CSS会在仓储层通过Purify和
static_content进行清理,草稿和发布流程均会执行。新的写入流程必须经过sanitizeStaticCss()。sanitizeOptions() - 每个渠道仅一个页脚。是单例,在控制器端进行服务端防护——而非仅在UI中隐藏该类型。
footer_links - 每次更改都清除页面缓存。FPC会监听、
section.create.after和section.update.after事件;section.delete.before和footer_links会在每个页面的布局中加载,因此这些更改会清除整个缓存而非仅首页缓存。services_content - 触发前后事件。每个操作都会触发一对事件——、
section.create.*、section.update.*、section.delete.*、section.draft.save.*、section.draft.discard.*、section.media.upload.*。新操作必须触发这两类事件,否则FPC和第三方监听器会遗漏相关变更。section.reorder.* - 防范在其他标签页中删除Section的情况。每个操作都会通过进行解析,若Section不存在则返回“已不存在”的提示而非500错误。
sectionOrFail() - Section的媒体目录会在删除时由移除,而非由控制器处理。
SectionObserver
必备子技能: 在执行任何更改前,请使用bagisto-change-verification。