PHPackages                             cita/silverstripe-modular - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. cita/silverstripe-modular

ActiveSilverstripe-vendormodule[Framework](/categories/framework)

cita/silverstripe-modular
=========================

CitaNZ's modular for SilverStripe 4

v1.0.0(4y ago)01MITPHP

Since Nov 13Pushed 4y ago4 watchersCompare

[ Source](https://github.com/CITANZ/silverstripe-modular)[ Packagist](https://packagist.org/packages/cita/silverstripe-modular)[ Docs](https://github.com/CITANZ/silverstripe-modular)[ RSS](/packages/cita-silverstripe-modular/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7f19b2827b8bad35e3ab9670434da0804c24e1dc38f39161ceb9b9743090c6b3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f434954414e5a2f73696c7665727374726970652d6d6f64756c61722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/CITANZ/silverstripe-modular/?branch=master)[![Build Status](https://camo.githubusercontent.com/529aafad8043877ac8c6cecb26e13b342cbfd91aa044a4dfcb4179c18850568a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f434954414e5a2f73696c7665727374726970652d6d6f64756c61722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/CITANZ/silverstripe-modular/build-status/master)[![Code Intelligence Status](https://camo.githubusercontent.com/81ff7171c772c75e7c0cb7139516be9746fe5dd5fc631534dc2e76772fc71c9d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f434954414e5a2f73696c7665727374726970652d6d6f64756c61722f6261646765732f636f64652d696e74656c6c6967656e63652e7376673f623d6d6173746572)](https://scrutinizer-ci.com/code-intelligence)

CitaNZ's SilverStripe modular module
====================================

[](#citanzs-silverstripe-modular-module)

Requires: `SilverStripe 4.0+`

CitaNZ Modular is a lightweight block module which uses `ManymanyList` to link the pages and the content blocks, and builds the site with the "modulated" concept.

It not only allows the users to reuse the same blocks on different pages across site, but also give the developer a safe fall protection when a block class becomes unavailable (e.g. a deleted block subclass will fall back to `Block::cass`, instead of crashing the block edit list in the CMS).

Installation
------------

[](#installation)

```
composer require cita/silverstripe-modular
sake dev/build flush=all

```

Make sure you also `/dev/build?flush=all` on the web too

Enable Modular on the class
---------------------------

[](#enable-modular-on-the-class)

Please note: if the page's `Content` field is already in use, then DO NOT enable this module!!!

Add `$modulated` static variable to the class

```
...
class SomePageType extends Page
{
    ...
    private static $modulated = true;
    ...
}

```

and then flush the site cache (`/?flush=all`)

Build your on Modular blocks
----------------------------

[](#build-your-on-modular-blocks)

Create a new class, and extend it from `Cita\Modular\Model\Block`

```
...
use Cita\Modular\Model\Block;

class MyShmartBlock extends Block
{
    ...
    private static $icon_class = 'font-icon-block-content'; // choose an icon
    private static $singular_name = 'Content block'; // singular name is also the block type

    public function getPlain()
    {
        return 'Extract the text content on this block. It will be used for search purpose. If you are using your own search index implementation, then you don\'t need to worry about this';
    }

    public function getBlockSummary()
    {
        return 'Return a summary to explain what this block is about - this will be used on the block\'s gridfield';
    }
}

```

Allowing/Disallowing block types
--------------------------------

[](#allowingdisallowing-block-types)

below line will only allow `BlockA::class`, `BlockB::class` and `BlockC::class` on the page

```
private static $allowed_modulars = [BlockA::class, BlockB::class, BlockC::class]

```

below line will exclude `BlockA::class`, `BlockB::class` and `BlockC::class` from the available block types;

```
private static $disallowed_modulars = [BlockA::class, BlockB::class, BlockC::class]

```

Frontend
--------

[](#frontend)

To print the modular list, just place `$Modulars` in the `.ss` files where it's needed

```
The shmart page
$Modulars

```

Templating
----------

[](#templating)

When a new block subclass is created, the default Block class template (`Cita\Modular\Model\Block`) will be applied to keep the frontend page stick together. The next step is to create the new subclass's template (make sure it matches the correct namespace), and then flush the cache on the browser -- now all you need to do is to build your block's HTML in the template file and style it with your frontend skills.

### Overriding CitaNZ's modular default templates

[](#overriding-citanzs-modular-default-templates)

If you need to tweak the default block's HTML and/or change how the modular blocks get listed on the page, please follow the steps:

1. cp -rf `vendor/cita/silverstripe-modular/templates/Cita` `your_theme/templates/.` (replace `your_theme` accordingly...)
2. flush (on the browser)
3. inspect the `.ss` files in it
4. do your thing

Caching
-------

[](#caching)

To enable cache for a particular block type, add below to the block type's class

```
private static $cache_enabled = true;

```

and define the `getCacheInvalidator` function, and build the conditions for when the cache should be invalidated.

Below is the default invalidator:

```
public function getCacheInvalidator()
{
    $prefix = str_replace('\\', '_' , strtolower(__CLASS__));

    return $prefix . '__' . ($this->exists() ? ($this->ID . '__' . strtotime($this->LastEdited)) : time());
}

```

It's looking at the block type, block id, and the last edited datetime.

Flex Block
----------

[](#flex-block)

Flex block offers you a quick way to group different blocks in a flex `row`. If you are using `Vuetify` or `Bootstrap` or something similar in your frontend stacks, then all you need to do is to set the column sizes in the CMS. Otherwise, you will have to implement the `flexbox` by yourself.

Questions?
----------

[](#questions)

Q: Why don't you...

A: Pull request plz

Q: I need to do such such such... so can you add this feature blah blah blah...

A: This module is meant to be lightweight, so let's keep it that way. I offer the nose pick, but I don't do the pick! (bet you don't want that either!)

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1638d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0395e460ef8e7579fc3f6e426d16bd0fed2b54de4ef5611d49494b0d6ee240be?d=identicon)[leochenftw](/maintainers/leochenftw)

---

Top Contributors

[![leochenftw](https://avatars.githubusercontent.com/u/8662044?v=4)](https://github.com/leochenftw "leochenftw (5 commits)")

---

Tags

silverstripeblockmodularcontent\_block

### Embed Badge

![Health badge](/badges/cita-silverstripe-modular/health.svg)

```
[![Health](https://phpackages.com/badges/cita-silverstripe-modular/health.svg)](https://phpackages.com/packages/cita-silverstripe-modular)
```

###  Alternatives

[silverstripe/cms

The SilverStripe Content Management System

5163.4M1.3k](/packages/silverstripe-cms)[dnadesign/silverstripe-elemental

Elemental pagetype and collection of Elements

1151.0M254](/packages/dnadesign-silverstripe-elemental)[silverstripe/behat-extension

SilverStripe framework extension for Behat

32564.2k5](/packages/silverstripe-behat-extension)[cwp/cwp

CWP features module. We strongly recommend using it for all new sites. Future features will be delivered here.

11221.1k5](/packages/cwp-cwp)[axllent/silverstripe-version-truncator

Automatically delete old versioned Silverstripe records from the database

3673.1k3](/packages/axllent-silverstripe-version-truncator)[oddnoc/silverstripe-artefactcleaner

Find and optionally delete unused tables, columns and indexes in a SilverStripe database

1419.0k3](/packages/oddnoc-silverstripe-artefactcleaner)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
