PHPackages                             zirak/widget-pages-extension - 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. zirak/widget-pages-extension

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

zirak/widget-pages-extension
============================

Freely inspired to burnbright/silverstripe-widgetpages, add a Widget's Gridfield to the extended pages

1.0.9(8y ago)65.8k41GPL-2.0PHP

Since Apr 2Pushed 8y ago3 watchersCompare

[ Source](https://github.com/g4b0/silverstripe-widget-pages-extension)[ Packagist](https://packagist.org/packages/zirak/widget-pages-extension)[ RSS](/packages/zirak-widget-pages-extension/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (11)Used By (1)

Widgets Pages Extension
=======================

[](#widgets-pages-extension)

Freely inspired to burnbright/silverstripe-widgetpages, it adds Widget's Gridfields to the extended pages or DataObjects. Widgets Pages Extension is an enhancement for the actual widget module ().

Introduction
------------

[](#introduction)

This module is a workaround for an old and annoying widget module bug: [silverstripe/silverstripe-widgets#20](https://github.com/silverstripe/silverstripe-widgets/issues/20)It's also a Proof of Concept for an alternative way to manage widget through many\_many relationsiph rather than the actual has\_many relationsiph. Extending the widget behaviour with this module you can be able to link existing widgets instead of rewrite them again. Widgets are sortable inside their WidgetArea. Also DataObjects can have their widges.

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

[](#requirements)

- SilverStripe 3.1 or 3.2

### Installation

[](#installation)

Install the module through [composer](http://getcomposer.org):

```
composer zirak/widget-pages-extension

```

Extend the desired pages through the following yaml:

```
:::yml
Page:
  extensions:
    - WidgetPage

```

Define the WidgetAreas in the $has\_one relationship, and specify which $allowed\_widgets are ok for this page type

```
:::php
class Page extends SiteTree {

	private static $db = array(
	);
	private static $has_one = array(
			'HeaderBar' => 'WidgetArea',
			'FooterBar' => 'WidgetArea'
	);
	private static $allowed_widgets = array(
			'StandardWidget',
			'TwitterWidget',
			'FacebookWidget'
	);
}

```

Run a `dev/build`, and adjust your templates to include the resulting WidgetArea view by calling $WidgetArea function passing it the WidgetArea name as parameter. It will loops through all its widgets.

```
:::HTML

	HeaderBar

		$WidgetHolder

	FooterBar

		$WidgetHolder

```

To enable WidgetAreas in backend remove the check from "Inherit Sidebar From Parent" and save the page. The module will create the WidgetAreas and you're now able to start populating them. If you leave the flag on the page will search Widget in its Parent since it find the SiteTree root, then it stops and return a void WidgetArea.

After installing read carefully the *ISSUE* section at the end of this document. I'm working on a solution but it's not so easy (PR are welcome).

### Installing a widget

[](#installing-a-widget)

See widget module docs ().

### Adding widgets to other pages

[](#adding-widgets-to-other-pages)

You have to do a couple things to get a Widget to work on a page.

- Install the Widgets Pages Extension module, see above.
- Add one or more WidgetArea field to your Page.
- run dev/build?flush=all

**mysite/code/Page.php**

```
:::php
class Page extends SiteTree {

	private static $db = array(
	);
	// Add 4 WidgetAreas
	private static $has_one = array(
			'HeaderBar' => 'WidgetArea',
			'SidebarBar' => 'WidgetArea'
			'CenterWidgetArea' => 'WidgetArea'
			'FooterBar' => 'WidgetArea'
	);
	private static $allowed_widgets = array(
			'StandardWidget',
			'TwitterWidget',
			'FacebookWidget'
	);
}

```

In this case, you need to alter your templates to loop over $WidgetArea(HeaderBar), $WidgetArea(SidebarBar), $WidgetArea(CenterWidgetArea) and $WidgetArea(FooterBar).

Writing your own widgets
------------------------

[](#writing-your-own-widgets)

See widget module docs ().

Adding widgets to DataObjects
-----------------------------

[](#adding-widgets-to-dataobjects)

A DataObject can be renderd as a page, it just need a Route and a Controller. With Widgets Pages Extension also DataObjects can have their Widgets. A sample is following:

### The DataObject

[](#the-dataobject)

**mysite/code/DoSurfboard.php**

```
:::php
class DoSurfboard extends DataObject {

	private static $db = array(
			'Name' => 'Varchar',
			'Color' => 'Varchar'
	);
	private static $has_one = array(
			'LeftSidebar' => 'WidgetArea'
	);
	private static $summary_fields = array (
			'Name',
			'Color'
	);

}

```

### Adding Widgets Pages Extension to DataObject

[](#adding-widgets-pages-extension-to-dataobject)

**mysite/code/\_config/extensions.yml**

```
:::yml
---
Name: my-extensions
---
DoSurfboard:
	extensions:
		- WidgetDataObject

```

### The route

[](#the-route)

**mysite/code/\_config/routes.yml**

```
:::yml
---
Name: myroutes
After: framework/routes#coreroutes
---
Director:
		rules:
				'surfboard//$ID!': 'ShowSurfboard'

```

### The Controller

[](#the-controller)

**mysite/code/Controllers/ShowSurfboard.php**

```
:::php
class ShowSurfboard extends ContentController {

	private static $url_handlers = array('$ID!' => 'handleAction');

	public function index(SS_HTTPRequest $req) {
		$id = $req->param('ID');

		// Use theme from the site config
		if (($config = SiteConfig::current_site_config()) && $config->Theme) {
			SSViewer::set_theme($config->Theme);
		}
		$themedir = $_SERVER['DOCUMENT_ROOT'] . '/' . SSViewer::get_theme_folder() . '/templates/';

		$surfboard = DataObject::get_by_id('DoSurfboard', $id);

		if ($surfboard) {
			//Return our $Data array to use on the page
			$Data = array('DoSurfboard' => $surfboard);
			$this->Customise($Data);
			return $this->renderWith($themedir . 'ShowSurfboard.ss');
		} else {
			//Not found
			return $this->httpError(404, 'Not found');
		}
	}
}

```

### The Template

[](#the-template)

**themes/theme-name/templates/ShowSurfboard.ss**

```

$Name
$Color

	LeftSidebar

		$WidgetHolder

```

TODO
----

[](#todo)

- Move $InheritSideBar in pages, in order to have the abilty to inherit only some widget area
- Fix the error listed below in ISSUE section, maybe with a task that re-publish every published page

ISSUE
-----

[](#issue)

After installing this module you need to re-publish existing pages where you want to use widgets, because of UnsavedRationList. If you don't re-publish the pages you will get the following error: Error at framework/model/UnsavedRelationList.php line 307: Uncaught LogicException: byID can't be called on an UnsavedRelationList.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 89.2% 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 ~145 days

Recently: every ~163 days

Total

10

Last Release

3168d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/11ee3ded134711b9ff1d704b1d448a7d3fdfe1b5f5b2e2809cda7eeac8356de5?d=identicon)[g4b0](/maintainers/g4b0)

---

Top Contributors

[![g4b0](https://avatars.githubusercontent.com/u/2427390?v=4)](https://github.com/g4b0 "g4b0 (33 commits)")[![cjsewell](https://avatars.githubusercontent.com/u/1856199?v=4)](https://github.com/cjsewell "cjsewell (4 commits)")

---

Tags

silverstripewidgets

### Embed Badge

![Health badge](/badges/zirak-widget-pages-extension/health.svg)

```
[![Health](https://phpackages.com/badges/zirak-widget-pages-extension/health.svg)](https://phpackages.com/packages/zirak-widget-pages-extension)
```

###  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)[sheadawson/silverstripe-blocks

An alternative to the SilverStripe Widgets module.

5955.5k5](/packages/sheadawson-silverstripe-blocks)[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)[undefinedoffset/silverstripe-advancedwidgeteditor

Replaces the Widget Editor to enable support for advanced form fields such as UploadField

101.3k](/packages/undefinedoffset-silverstripe-advancedwidgeteditor)[mateusz/frontend

Provides frontend widgets that nicely integrate with a SilverStripe site.

143.0k1](/packages/mateusz-frontend)

PHPackages © 2026

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