mod-lab/craft-restrict-entry-type-quantity
Composer 安装命令:
composer require mod-lab/craft-restrict-entry-type-quantity
包简介
Limit how many entries of a given entry type can exist per site in Craft CMS
README 文档
README
Restricts how many entries of a given entry type may exist per site. Useful when entry types represent page designs and some pages (e.g. a Homepage) should only ever be built once.
Restrictions are controlled entirely from a config file — there is no control panel settings UI.
Requirements
This plugin requires Craft CMS 5.10.0 or later, and PHP 8.2 or later.
Installation
composer require mod-lab/craft-restrict-entry-type-quantity php craft plugin/install restrict-entry-type-quantity
Configuration
Create config/restrict-entry-type-quantity.php in your Craft project and map entry type handles to the maximum number of entries allowed:
<?php return [ 'restrictions' => [ 'homepage' => 1, 'contactPage' => 1, ], ];
Multi-environment configs work like any Craft plugin config file:
<?php return [ '*' => [ 'restrictions' => [ 'homepage' => 1, ], ], 'dev' => [ 'restrictions' => [], ], ];
How it works
When an entry type is at its limit, the plugin:
- removes it from the entry type options for new entries in the control panel, and
- blocks any save that would exceed the limit with a validation error on the entry — including saves via GraphQL, the console, or
Craft::$app->elements->saveElement().
Semantics
- Per site. On multi-site installs, each site gets its own count — e.g. every site can have its own Homepage.
- Only enabled entries count. A disabled entry doesn't occupy a slot. To swap out a restricted page, disable (or delete) the existing one first — disabling is always allowed.
- Drafts are free. Editors can create and work on drafts of a restricted type without errors; the limit is enforced when the draft is applied/published. Revisions never count.
- Editing the existing entry always works. An entry never counts against itself, so re-saving the one allowed Homepage is fine.
- Unlisted entry types are unlimited.
- Nested entries are ignored. Entry types used inside Matrix/CKEditor fields aren't counted or restricted, even if their handle appears in the config.
- Unknown handles are ignored silently, since an entry type may only exist in some environments.
- A limit of
0effectively retires an entry type — it's hidden from type options and can never be saved enabled again.
Known limitations
- The "New entry" button on the entry index is per-section and can't be filtered per entry type, so in a section where every entry type is maxed out the button still appears. The editor can open a fresh draft, but publishing it is blocked with a clear validation error.
- Add limits after reconciling existing content. If a site already has more enabled entries of a type than the new limit, those extras keep working through bulk resaves, but re-saving one from the control panel will fail until the count is brought under the limit (by disabling or deleting extras).
mod-lab/craft-restrict-entry-type-quantity 适用场景与选型建议
mod-lab/craft-restrict-entry-type-quantity 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mod-lab/craft-restrict-entry-type-quantity 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mod-lab/craft-restrict-entry-type-quantity 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mod-lab/craft-restrict-entry-type-quantity 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This module allows drag & drop grouping of items in a GridField
Adds text size controls and text-to-speech controls to Flarum discussion content.
Native Blade date, datetime, and date range pickers.
Symfony and Flysystem integration for the maintained KCFinder continuation.
Laravel integration for the maintained KCFinder continuation.
PHPStan rules shared across KnpLabs organization projects
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-15