承接 mod-lab/craft-restrict-entry-type-quantity 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

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 0 effectively 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 mod-lab/craft-restrict-entry-type-quantity 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-07-15