定制 klehm/content-blocks-kit 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

klehm/content-blocks-kit

Composer 安装命令:

composer require klehm/content-blocks-kit

包简介

Ready-to-use block types for ContentBlocks (Text, Title, Image, Tabs).

README 文档

README

Ready-to-use block types for klehm/content-blocks.

The kit is self-contained: no Tailwind/Bootstrap, no LiipImagine, no icon library. Every block renders neutral cb-kit-* markup styled by a single shipped stylesheet, so it drops into any host regardless of its CSS setup.

Included blocks

Type What it is
title Heading with visual size, semantic tag, and palette text color
text Plain paragraph text with palette text color
rich_text WYSIWYG (TinyMCE) rich text
image Image with size preset / custom size, fit, align, link, caption, rounded corners
gallery Image grid or slider (arrows) with columns, fit, rounded corners
button Call-to-action button (variants, sizes, alignment)
card Image/title/text/button tiles as a grid or list
list Bulleted / checkmark / numbered list
icon A single icon from the shipped icon set
alert Info / success / warning / error callout
divider Horizontal rule (style + color)
accordion Collapsible panels (native <details>, zero JS)
table Columns + rows data table
embed Responsive YouTube / Vimeo embed
breadcrumb Breadcrumb trail
html_raw Raw HTML escape hatch (disabled by default — opt in)
tabs Tabbed panels

Installation

composer require klehm/content-blocks klehm/content-blocks-kit

The blocks are auto-registered via Symfony autoconfiguration — no config needed to get all of them.

Front stylesheet (required)

Kit blocks render with neutral cb-kit-* classes styled by a stylesheet the kit serves at a public route. Include it once in your front layout (it also flows into the builder preview):

<link rel="stylesheet" href="{{ path('content_blocks_kit_asset_css') }}">

Retheme by overriding the --cb-kit-* custom properties (or the classes) in your own stylesheet loaded after it.

Stimulus controllers

Enable the kit's controllers in your host assets/controllers.json under the @klehm/content-blocks-kit package: cb-tinymce (rich text) and cb-gallery (gallery slider).

Configuring blocks

Each block exposes four levers under content_blocks_kit.blocks.<type>:

Key Purpose
enabled false un-registers the block's service — it never reaches the picker.
options Block-level knobs (e.g. max_columns), merged over the block's coded ones.
choices Per-field allow-list restricting/reordering a ChoiceType field.
defaults Per-field overrides of a block's initial data (what a new block starts with).
# config/packages/content_blocks_kit.yaml
content_blocks_kit:
    blocks:
        tabs: { enabled: false }                # drop a block entirely
        html_raw: { enabled: true }             # opt into a default-disabled block
        gallery:
            options: { max_columns: 4 }         # cap the column choices
        button:
            choices:
                variant: [primary, secondary]   # only these two, in this order, in the picker
                size: [md, lg]
            defaults:
                variant: secondary              # new buttons start as "secondary"
                align: center
        title:
            defaults: { size: h1 }              # new titles default to h1 size

Notes:

  • Blocks omitted from config are enabled with their coded defaults — except html_raw, which is disabled by default: it renders unescaped markup ({{ html|raw }}), so it trusts its editors and must be opted in explicitly.
  • choices values not offered by the block are ignored; an empty or all-invalid list falls back to the full set (the select is never empty). Restricting the picker does not invalidate content already stored with a now-hidden value — validation still accepts the block's full coded set.
  • defaults only apply to fields the block declares; unknown keys are ignored.

Colors

All color fields — icon and divider colors, the title and text blocks' text color, and the rich-text (TinyMCE) swatches — draw from the one core palette declared in content_blocks.palette (see the main package README). Add a named color there once and it appears everywhere:

# config/packages/content_blocks.yaml
content_blocks:
    palette:
        - { label: 'Brand', color: '#eb0540' }

Discovering the surface

List every block with its options, choice fields (default marked *) and data defaults — read straight from the code, so it never goes stale:

bin/console content-blocks-kit:blocks          # all blocks
bin/console content-blocks-kit:blocks button   # one block

Overriding block templates

Drop a file at the matching relative path under templates/bundles/ContentBlocksKitBundle/ to override any template shipped by this kit — e.g. templates/bundles/ContentBlocksKitBundle/block/image/view.html.twig overrides the image view.

Requires klehm/content-blocks-kit >= 0.1.0-alpha.4 for overrides to take priority. Earlier versions manually registered the vendor templates/ path under @ContentBlocksKit, which shadowed the host's templates/bundles/ContentBlocksKitBundle/ directory.

File uploads

ImageBlock uses the main package's upload brick (ImageUploadType, the /_content-blocks/upload endpoint and FileStorageInterface — all in klehm/content-blocks now). Enable it via the bundle config:

# config/packages/content_blocks.yaml
content_blocks:
    upload:
        dir: '%kernel.project_dir%/public/uploads/content-blocks'
        public_prefix: '/uploads/content-blocks'

Documentation & contributing

Full documentation and development setup live in the monorepo: github.com/klehm/content-blocks-project

License

MIT

klehm/content-blocks-kit 适用场景与选型建议

klehm/content-blocks-kit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「symfony」 「blocks」 「symfony-bundle」 「page-builder」 「content-blocks」 「symfony-ux」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 klehm/content-blocks-kit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 klehm/content-blocks-kit 我们能提供哪些服务?
定制开发 / 二次开发

基于 klehm/content-blocks-kit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 9
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 45
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-29