PHPackages                             sheadawson/silverstripe-blocks - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. sheadawson/silverstripe-blocks

ActiveSilverstripe-module[Utility &amp; Helpers](/categories/utility)

sheadawson/silverstripe-blocks
==============================

An alternative to the SilverStripe Widgets module.

1.1.3(7y ago)5955.5k↓84%56[22 issues](https://github.com/sheadawson/silverstripe-blocks/issues)[5 PRs](https://github.com/sheadawson/silverstripe-blocks/pulls)5PHP

Since Dec 8Pushed 3y ago15 watchersCompare

[ Source](https://github.com/sheadawson/silverstripe-blocks)[ Packagist](https://packagist.org/packages/sheadawson/silverstripe-blocks)[ Docs](http://github.com/sheadawson/silverstripe-blocks)[ RSS](/packages/sheadawson-silverstripe-blocks/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (6)Versions (25)Used By (5)

SilverStripe Blocks
===================

[](#silverstripe-blocks)

[![Build Status](https://camo.githubusercontent.com/4e74705e09ca931769442cf50defbd5dc5512cc05f71a0d2b881bb32e08e0872/68747470733a2f2f7472617669732d63692e6f72672f73686561646177736f6e2f73696c7665727374726970652d626c6f636b732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sheadawson/silverstripe-blocks)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ef010972d42d3362d6a337f898120bc0815b7d8d798826c35ecf6349c5c41ff3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73686561646177736f6e2f73696c7665727374726970652d626c6f636b732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sheadawson/silverstripe-blocks/?branch=master)[![codecov](https://camo.githubusercontent.com/7cab9ca981abc374959898b84d9c1ac28fa6c3c5b30977f9940826aaa1100925/68747470733a2f2f636f6465636f762e696f2f67682f73686561646177736f6e2f73696c7665727374726970652d626c6f636b732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/sheadawson/silverstripe-blocks)

The Blocks modules aims to provide developers with a flexible foundation for defining reusable blocks of content or widgets that can be managed in the CMS.

Notice
------

[](#notice)

This module is no longer maintained. If you would like to adopt it and give it a good home please submit your interest and I will be happy to discuss.

Features
--------

[](#features)

- Blocks are Versioned
- Blocks with Forms possible (through `BlockController`)
- Drag and Drop re-ordering of Blocks
- Duplicate Blocks
- BlockSets for global blocks
- Allow exclusion of any page types from using Blocks
- Allow disabling of default/example block type - ContentBlock
- Allow disabling of specific blocks

Upgrading from 0.x
------------------

[](#upgrading-from-0x)

See [the upgrade guide](docs/upgrading.md)

Requirements
------------

[](#requirements)

- SilverStripe CMS ^4.0
- [GridFieldExtensions](https://github.com/silverstripe-australia/silverstripe-gridfieldextensions)
- [MultivalueField](https://github.com/nyeholt/silverstripe-multivaluefield)
- [GridField BetterButtons](https://github.com/unclecheese/silverstripe-gridfield-betterbuttons)

Recommended
-----------

[](#recommended)

- [GridField Copybutton](https://github.com/unisolutions/silverstripe-copybutton) (duplication of blocks, from BlockAdmin)
- [GridField Sitetree Buttons](https://github.com/micschk/silverstripe-gridfieldsitetreebuttons) (Edit pages directly from a Block's 'used on page' list)

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

[](#installation)

```
composer require sheadawson/silverstripe-blocks
```

Install via composer, run `dev/build`

Quickstart
----------

[](#quickstart)

### 1. Define Block Areas and Settings for your project in `mysite/_config/config.yml`

[](#1-define-block-areas-and-settings-for-your-project-in-mysite_configconfigyml)

```
SheaDawson\Blocks\BlockManager:
	areas:
		Sidebar: true # a Sidebar area will be available on all page types
		BeforeContent:
			only: HomePage # a BeforeContent area will be available only on HomePage page types
		AfterContent:
			except: HomePage # a AfterContent area will be available on all page types except HomePage
		Footer: true # a Footer area will be available on all page types
	options:
		#use_blocksets: false # Whether to use BlockSet functionality (default if undeclared: true)
		#use_extra_css_classes: true # Whether to allow cms users to add extra css classes to blocks (default if undeclared: false)
		#prefix_default_css_classes: 'myprefix--' # prefix the automatically generated CSSClasses based on class name (default if undeclared: false)
		#pagetype_whitelist: # Enable the Blocks tab only pages of these types (optional)
		#  - HomePage
		#pagetype_blacklist: # Disable the Blocks tab on pages of these types (optional)
		#  - ContactPage
		#disabled_blocks: #allows you to disable specific blocks (optional)
		#  - ContentBlock
		#use_default_blocks: false # Disable/enable the default Block types (ContentBlock) (default if undeclared: true)
		#block_area_preview: false # Disable block area preview button in CMS (default if undeclared: true)
```

Remember to run `?flush=1` after modifying your `.yml` config to make sure it gets applied.

### 2. Add Block Areas to your templates

[](#2-add-block-areas-to-your-templates)

Adding the `BeforeContent` and `AfterContent` blocks would look something like

```

	$Title
	$BlockArea(BeforeContent)
	$Content
	$BlockArea(AfterContent)

```

`$BlockArea(BeforeContent)` will loop over and display all blocks assigned to the `BeforeContent` area on the current page

You can limit a block area to a maximum number of blocks using the second limit parameter

```

	$BlockArea(NewsBlocks, 3)

```

### 3. Add Blocks to a page in the CMS

[](#3-add-blocks-to-a-page-in-the-cms)

You will now be able to add Blocks to Pages via the CMS page edit view and in the Blocks model admin. You can also define "BlockSets" in the Blocks model admin. BlockSets can be used to apply a common collection of blocks to pages that match the criteria you define on the set.

This module ships with a basic `ContentBlock`, but this can be disabled through the `BlockManager::use\_default\_blocks config.

Help
----

[](#help)

### Restrict Blocks to viewer groups or logged in users

[](#restrict-blocks-to-viewer-groups-or-logged-in-users)

When editing a block, you can restrict who can see it in the frontend by selecting "logged in users" or "users from these groups" under the Viewer Groups tab.

### Templates

[](#templates)

There are 2 types of templates you should be aware of.

### BlockArea Template

[](#blockarea-template)

The `BlockArea` template is responsible for looping over and rendering all blocks in that area. You can override this by creating a copy of the default `BlockArea.ss` and placing it in your `templates/Includes` folder.

It's likely that your block areas may require different templates. You can achieve this by creating a `BlockArea_{AreaName}.ss` template.

### Block Template

[](#block-template)

Each subclass of Block requires it's own template with the same name as the class. So, `SlideshowBlock.php` would have a `SlideshowBlock.ss` template. If your block requires different templates depending on the `BlockArea` it's in, you can create `SlideshowBlock_{AreaName}.ss`

The current page scope can be accessed from Block templates with `$CurrentPage`.

### Block Area Preview

[](#block-area-preview)

To aid website admins in identifying the areas they can apply blocks to, a "Preview Block Areas for this page" button is available in the cms. This opens the frontend view of the page in a new tab with `?block_preview=1`. In Block Preview mode, Block Areas in the template are highlighted and labeled.

There is some markup required in your BlockArea templates to facilitate this: The css class `block-area` and the `data-areaid='$AreaID'` attribute.

```

		$BlockHTML

```

### Form Blocks

[](#form-blocks)

As of v1.0 Blocks can now handle forms. See this gist for as an example:

- [Block with Form example](https://gist.github.com/sheadawson/e584b0771f6b124701b4)

### Remove the Blocks button from the main CMS menu

[](#remove-the-blocks-button-from-the-main-cms-menu)

The BlockAdmin section is not always needed to be used. If you wish, you can remove the button from the menu by inserting this to `mysite/_config.php`:

```
CMSMenu::remove_menu_item('BlockAdmin');
```

### Block icons

[](#block-icons)

Until this module properly supports icons, you can define icons by creating a `getTypeForGridfield` method in your block. Here's an example that uses font awesome:

```
public function getIcon()
{
		return '';
}
public function getTypeForGridfield()
{
		$icon = $this->getIcon();
		if ($icon) {
				$obj = HTMLText::create();
				$obj->setValue($icon);
				return $obj;
		} else {
				return parent::getTypeForGridfield();
		}
}
```

Translatable Blocks
-------------------

[](#translatable-blocks)

For creating Blocks with translatable content, using the [translatble module](https://github.com/silverstripe/silverstripe-translatable), see [this gist](https://gist.github.com/thezenmonkey/6e6730023af553f12e3ab762ace3b08a) for a kick start.

Screenshots
-----------

[](#screenshots)

[![](docs/images/overview-1.0.png)](docs/images/overview-1.0.png)Overview

[![](docs/images/preview-1.0.png)](docs/images/preview-1.0.png)Preview of block locations

[![](docs/images/edit-1.0.png)](docs/images/edit-1.0.png)Edit a block

[![](docs/images/existing-1.0.png)](docs/images/existing-1.0.png)Add an existing block

TODO
----

[](#todo)

- Re-add: Sorting primarily by Area (in order of declaration in config), on Pages (removed in favor of dr'ndr sorting)
- Add icon/pic to base Block as method of recognition when dealing with lots of different blocks

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community36

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 73.9% 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

Every ~74 days

Recently: every ~232 days

Total

23

Last Release

2584d ago

Major Versions

0.1.0 → 1.0.02015-01-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ca23b453a4fc5ac237ad4fcc512f68fab5c7b124f403cad1a5848b3fffb6aa2?d=identicon)[sheadawson](/maintainers/sheadawson)

---

Top Contributors

[![sheadawson](https://avatars.githubusercontent.com/u/1166136?v=4)](https://github.com/sheadawson "sheadawson (173 commits)")[![anselmdk](https://avatars.githubusercontent.com/u/1316533?v=4)](https://github.com/anselmdk "anselmdk (11 commits)")[![jsirish](https://avatars.githubusercontent.com/u/1163643?v=4)](https://github.com/jsirish "jsirish (5 commits)")[![Taitava](https://avatars.githubusercontent.com/u/13002142?v=4)](https://github.com/Taitava "Taitava (4 commits)")[![xini](https://avatars.githubusercontent.com/u/1152403?v=4)](https://github.com/xini "xini (3 commits)")[![hdpero](https://avatars.githubusercontent.com/u/13778690?v=4)](https://github.com/hdpero "hdpero (3 commits)")[![jackoconnor21](https://avatars.githubusercontent.com/u/8939444?v=4)](https://github.com/jackoconnor21 "jackoconnor21 (3 commits)")[![jonom](https://avatars.githubusercontent.com/u/1079425?v=4)](https://github.com/jonom "jonom (3 commits)")[![micschk](https://avatars.githubusercontent.com/u/1005986?v=4)](https://github.com/micschk "micschk (3 commits)")[![beerbohmdo](https://avatars.githubusercontent.com/u/905241?v=4)](https://github.com/beerbohmdo "beerbohmdo (3 commits)")[![chillu](https://avatars.githubusercontent.com/u/111025?v=4)](https://github.com/chillu "chillu (3 commits)")[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (3 commits)")[![tractorcow](https://avatars.githubusercontent.com/u/936064?v=4)](https://github.com/tractorcow "tractorcow (3 commits)")[![christopherdarling](https://avatars.githubusercontent.com/u/178039?v=4)](https://github.com/christopherdarling "christopherdarling (2 commits)")[![doniz](https://avatars.githubusercontent.com/u/4441455?v=4)](https://github.com/doniz "doniz (2 commits)")[![nyeholt](https://avatars.githubusercontent.com/u/161730?v=4)](https://github.com/nyeholt "nyeholt (2 commits)")[![MichaelJJames](https://avatars.githubusercontent.com/u/6860174?v=4)](https://github.com/MichaelJJames "MichaelJJames (1 commits)")[![diegotrout](https://avatars.githubusercontent.com/u/13478687?v=4)](https://github.com/diegotrout "diegotrout (1 commits)")[![alexoconner](https://avatars.githubusercontent.com/u/6382224?v=4)](https://github.com/alexoconner "alexoconner (1 commits)")[![mooror](https://avatars.githubusercontent.com/u/6110819?v=4)](https://github.com/mooror "mooror (1 commits)")

---

Tags

silverstripewidgetsblocks

### Embed Badge

![Health badge](/badges/sheadawson-silverstripe-blocks/health.svg)

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

###  Alternatives

[silverstripe/userforms

UserForms enables CMS users to create dynamic forms via a drag and drop interface and without getting involved in any PHP code

1321.1M83](/packages/silverstripe-userforms)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[symbiote/silverstripe-advancedworkflow

Adds configurable workflow support to the CMS, with a GUI for creating custom workflow definitions.

46299.9k9](/packages/symbiote-silverstripe-advancedworkflow)[silverstripe/widgets

Widgets are small pieces of functionality such as showing the latest Comments or Flickr Photos. They normally display on the sidebar of your website.

37418.6k20](/packages/silverstripe-widgets)[silverstripe/sharedraftcontent

Share draft page content with non-CMS users

21419.6k11](/packages/silverstripe-sharedraftcontent)[bummzack/page-blocks

Modular content-blocks for SilverStripe pages

135.3k](/packages/bummzack-page-blocks)

PHPackages © 2026

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