spanjaan/wn-snowflake-plugin
Composer 安装命令:
composer require spanjaan/wn-snowflake-plugin
包简介
Snowflake plugin is dynamic content manager for Winter CMS
关键字:
README 文档
README
Fork Information and Acknowledgments
This plugin was forked from skripteria/snowflake to spanjaan/snowflake. This fork aims to enhance and extend the functionalities of the original plugin to better meet the needs of various user types within Winter CMS.
A big thank you to all contributors and the Winter CMS community for their continued support and inspiration!
Version History
- 1.0.5: Initial release
Installation with Composer
To install Snowflake, run the following commands:
composer require spanjaan/wn-snowflake-plugin php artisan winter:up
Why a New "CMS" Within a CMS?
In real-life scenarios, there are at least four different user types that need to be considered:
- Technical Developer: Has some knowledge of how to build custom functionality.
- Web Designer: Primarily interested in web design rather than backend development.
- Web-Interested End User: Has a vision of how things should look and tries to make it happen. Not afraid of experimenting with customization, similar to a typical WordPress user.
- Non-Technical User: Occasionally needs to do some content editing due to job or business requirements.
The first three user types are usually considered when discussing how a CMS should function. However, the last user type is often overlooked. When developing a site for a paying customer, the non-technical user is the one you will most likely deal with in the end.
As a result, you need to make content management foolproof and hide everything except the specific pieces of content that need to be managed.
Snowflake addresses this by leveraging the power of the Winter CMS backend framework.
Using Snowflake
Once installed, you first need to add the Snowflake component to any CMS Layout you want to use it with. This will enable the Snowflake Twig filter on the Layout itself and any Page using this Layout.
On these CMS pages, you can now add content variables using the 'sf' Twig filter, for example:
<h1>{{ 'my_headline' | sf('text', 'My awesome headline', 'Main headline of this page.') }}</h1>
The first part ('my_headline') is the Snowflake key used to render the content. The Snowflake key acts like a normal Twig variable and references the content.
Every Snowflake key must be unique within a given Page but may conflict with keys from other Pages. When adding Snowflake keys to a Layout, name collisions with Pages can occur. It is generally recommended to prefix Snowflake keys in Layouts (e.g., 'layout_my_headline').
The 'sf' filter takes up to three arguments:
- Argument 1: Defines the type of content. This controls which backend widget is used for content management.
- Argument 2 (optional): Allows setting a default value for the content. The default value has no effect on the types 'image', 'file', 'date', 'mediaimage', and 'mediafile'.
- Argument 3 (optional): Adds a description for the user responsible for content management.
Note: The characters ',' (comma) and '|' (pipe) must not be used within arguments.
Currently, Snowflake supports seven standard types and five special ones.
Standard Types:
text(simple text input, e.g., for headlines)color(Winter CMS color picker)markdown(Winter CMS markdown editor)richeditor(Winter CMS rich text editor)code(Winter CMS code editor)date(Winter CMS date picker)textarea(plain textarea field)
Special Types:
-
image:Used to control images and utilizes the Winter CMS image upload widget. It requires two values for rendering: the image path and the
altattribute. To handle this, the variable must pass two values.Example:
<img src="{{ 'my_image' | sf('image', '', 'This is the hero image on this page') }}" alt="{{ my_image___alt }}">
Note: The
'sf'filter is only added once in thesrcattribute; thealtattribute uses the same key with the suffix'__alt'. -
mediaimage:Similar to
'image', but'mediaimage'uses the Winter Media Library as the image source:<img src="{{ 'my_image' | sf('mediaimage', '', 'This is the hero image on this page') }}" alt="{{ my_image___alt }}">
-
file:Used to control file uploads. Like
image, it uses two values: the file path and the filename displayed in the link.Example:
<a href="{{ 'my_file' | sf('file', '', 'This is my uploaded file') }}">{{ my_file__name }}</a>
-
mediafile:Similar to
'file', but'mediafile'uses the Winter Media Library as the file source:<a href="{{ 'my_file' | sf('mediafile', '', 'This is my uploaded file') }}">{{ my_file__name }}</a>
-
link:Used for internal Winter CMS links. The
'link'type allows content managers to simply copy the full URL from the browser window without worrying about proper formatting. It is automatically converted into a clean relative link.
Synchronizing with the Snowflake Backend
If you are using the Winter CMS backend to edit your code, simply save your Page or Layout, and Snowflake will automatically create or update the respective records in the database.
Once a Snowflake key is removed (or renamed), it is handled as an unused database record based on the following logic:
- If existing content is present in the record: It is retained.
- If no content exists: It is deleted.
Alternatively, you can use a console command to sync all CMS Pages and Layouts:
php artisan snowflake:sync
To clean up all unused Snowflake keys (caution: this also deletes the associated content), use:
php artisan snowflake:sync --cleanup
spanjaan/wn-snowflake-plugin 适用场景与选型建议
spanjaan/wn-snowflake-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「cms」 「snowflake」 「wintercms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 spanjaan/wn-snowflake-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 spanjaan/wn-snowflake-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 spanjaan/wn-snowflake-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes
An ID Generator for PHP based on Snowflake Algorithm (Twitter announced).
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 34
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-29