SS4 compat: Update readme, docs, composer configuration and Travis build configuration

This commit is contained in:
Robbie Averill 2017-01-18 11:24:09 +13:00
parent f3b14df4e4
commit defb4bf134
8 changed files with 368 additions and 248 deletions

View File

@ -6,4 +6,4 @@ checks:
duplication: true duplication: true
filter: filter:
paths: [code/*, tests/*] paths: [src/*, tests/*]

View File

@ -1,31 +1,28 @@
# See https://github.com/silverstripe-labs/silverstripe-travis-support for setup details # See https://github.com/silverstripe/silverstripe-travis-support for setup details
sudo: false sudo: false
language: php language: php
php: php:
- 5.3
- 5.4
- 5.5 - 5.5
- 5.6 - 5.6
- 7.0 - 7.0
- 7.1
env: env:
- DB=MYSQL CORE_RELEASE=3.2 - DB=MYSQL CORE_RELEASE=master
matrix: matrix:
include: include:
- php: 5.6 - php: 5.6
env: DB=MYSQL CORE_RELEASE=3 env: DB=MYSQL CORE_RELEASE=master
- php: 5.6 - php: 5.6
env: DB=PGSQL CORE_RELEASE=3.2 env: DB=PGSQL CORE_RELEASE=master
allow_failures:
- php: 7.0
before_script: before_script:
- composer self-update || true - composer self-update || true
- git clone git://github.com/silverstripe-labs/silverstripe-travis-support.git ~/travis-support - git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss - php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
- cd ~/builds/ss - cd ~/builds/ss
- composer install - composer install

352
README.md
View File

@ -1,6 +1,6 @@
# Widgets Module # Widgets Module
[![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-widgets.png?branch=1.1)](http://travis-ci.org/silverstripe/silverstripe-widgets) [![Build Status](https://secure.travis-ci.org/silverstripe/silverstripe-widgets.png?branch=master)](http://travis-ci.org/silverstripe/silverstripe-widgets)
## Overview ## Overview
@ -9,7 +9,7 @@ the sidebar of your website.
## Requirements ## Requirements
* SilverStripe 3.2 * SilverStripe 4.0
### Installation ### Installation
@ -55,18 +55,28 @@ e.g.
**mysite/code/Page.php** **mysite/code/Page.php**
class Page extends SiteTree { ```php
... <?php
private static $has_one = array(
"MyWidgetArea" => "WidgetArea",
);
public function getCMSFields() { use SilverStripe\CMS\Model\SiteTree;
$fields = parent::getCMSFields(); use SilverStripe\Widgets\Form\WidgetAreaEditor;
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("MyWidgetArea")); use SilverStripe\Widgets\Model\WidgetArea;
return $fields;
} class Page extends SiteTree
} {
// ...
private static $has_one = array(
'MyWidgetArea' => WidgetArea::class
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Widgets', new WidgetAreaEditor('MyWidgetArea'));
return $fields;
}
}
```
In this case, you need to alter your templates to include the `$MyWidgetArea` placeholder. In this case, you need to alter your templates to include the `$MyWidgetArea` placeholder.
@ -94,71 +104,91 @@ An example widget is below:
**FlickrWidget.php** **FlickrWidget.php**
:::php ```php
<?php <?php
class FlickrWidget extends Widget {
private static $db = array(
"User" => "Varchar",
"Photoset" => "Varchar",
"Tags" => "Varchar",
"NumberToShow" => "Int"
);
namespace Yourname\MyWidget;
private static $defaults = array( use FlickrService;
"NumberToShow" => 8 use SilverStripe\Widgets\Model\Widget;
); use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
private static $title = "Photos"; class FlickrWidget extends Widget
private static $cmsTitle = "Flickr Photos"; {
private static $description = "Shows flickr photos."; private static $db = array(
'User' => 'Varchar',
'Photoset' => 'Varchar',
'Tags' => 'Varchar',
'NumberToShow' => 'Int'
);
public function Photos() { private static $defaults = array(
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js"); 'NumberToShow' => 8
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/effects.js"); );
Requirements::javascript("mashups/javascript/lightbox.js");
Requirements::css("mashups/css/lightbox.css");
$flickr = new FlickrService(); private static $title = 'Photos';
if($this->Photoset == "") { private static $cmsTitle = 'Flickr Photos';
$photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1); private static $description = 'Shows flickr photos.';
} else {
$photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1);
}
$output = new ArrayList(); public function Photos()
foreach($photos->PhotoItems as $photo) { {
$output->push(new ArrayData(array( // You'll need to install these yourself
"Title" => $photo->title, Requirements::javascript(THIRDPARTY_DIR . '/prototype/prototype.js');
"Link" => "http://farm1.static.flickr.com/" . $photo->image_path .".jpg", Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
"Image" => "http://farm1.static.flickr.com/" .$photo->image_path. "_s.jpg" Requirements::javascript('mashups/javascript/lightbox.js');
))); Requirements::css('mashups/css/lightbox.css');
}
return $output;
}
public function getCMSFields() { $flickr = new FlickrService();
return new FieldList( if ($this->Photoset == '') {
new TextField("User", "User"), $photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1);
new TextField("PhotoSet", "Photo Set"), } else {
new TextField("Tags", "Tags"), $photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1);
new NumericField("NumberToShow", "Number to Show") }
);
}
}
$output = new ArrayList();
foreach ($photos->PhotoItems as $photo) {
$output->push(
new ArrayData(
array(
'Title' => $photo->title,
'Link' => 'http://farm1.static.flickr.com/' . $photo->image_path .'.jpg',
'Image' => 'http://farm1.static.flickr.com/' .$photo->image_path. '_s.jpg'
)
)
);
}
return $output;
}
public function getCMSFields()
{
return new FieldList(
new TextField('User', 'User'),
new TextField('PhotoSet', 'Photo Set'),
new TextField('Tags', 'Tags'),
new NumericField('NumberToShow', 'Number to Show')
);
}
}
```
**FlickrWidget.ss** **FlickrWidget.ss**
:::ss ```
<% control Photos %> <% control Photos %>
<a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a> <a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a>
<% end_control %> <% end_control %>
```
## Releasing a widget ## Releasing a widget
Follow the [standard procedures defined for releasing a SilverStripe module](http://doc.silverstripe.org/framework/en/3.1/topics/module-development). Follow the [standard procedures defined for releasing a SilverStripe module](https://docs.silverstripe.org/en/4/developer_guides/extending/how_tos/publish_a_module).
Here is a composer template you can use. Here is a composer template you can use.
@ -178,8 +208,8 @@ You need to finish off / change:
"type": "silverstripe-module", "type": "silverstripe-module",
"keywords" : ["widget"], "keywords" : ["widget"],
"require": { "require": {
"silverstripe/framework": "3.*", "silverstripe/framework": "^4.0",
"silverstripe/cms": "3.*" "silverstripe/cms": "^4.0"
}, },
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"authors": [ "authors": [
@ -190,6 +220,11 @@ You need to finish off / change:
], ],
"extra" : { "extra" : {
"installer-name": "widgets_" "installer-name": "widgets_"
},
"autoload": {
"psr-4": {
"Yourname\\MyWidget\\": "src/"
}
} }
} }
``` ```
@ -203,27 +238,30 @@ define a merge variable in the Page Controller and include it in the Page Templa
This example creates an RSSWidget with the SilverStripe blog feed. This example creates an RSSWidget with the SilverStripe blog feed.
:::php ```php
public function SilverStripeFeed() { public function SilverStripeFeed()
$widget = new RSSWidget(); {
$widget->RssUrl = "http://feeds.feedburner.com/silverstripe-blog"; $widget = new RSSWidget();
return $widget->renderWith("WidgetHolder"); $widget->RssUrl = 'http://feeds.feedburner.com/silverstripe-blog';
} return $widget->renderWith('WidgetHolder');
}
```
To render the widget, simply include $SilverStripeFeed in your template: To render the widget, simply include `$SilverStripeFeed` in your template:
$SilverStripeFeed ```
$SilverStripeFeed
```
As directed in the definition of `SilverStripeFeed()`, the Widget will be rendered through the WidgetHolder template. This
is pre-defined at `widgets/templates/WidgetHolder.ss` and simply consists of:
As directed in the definition of SilverStripeFeed(), the Widget will be rendered through the WidgetHolder template. This ```
is pre-defined at `framework/templates/WidgetHolder.ss` and simply consists of: <div class="WidgetHolder">
<h3>$Title</h3>
:::ss $Content
<div class="WidgetHolder"> </div>
<h3>$Title</h3> ```
$Content
</div>
You can override the WidgetHolder.ss and Widget.ss templates in your theme too by adding WidgetHolder and Widget You can override the WidgetHolder.ss and Widget.ss templates in your theme too by adding WidgetHolder and Widget
templates to `themes/myThemeName/templates/Includes/` templates to `themes/myThemeName/templates/Includes/`
@ -233,25 +271,27 @@ templates to `themes/myThemeName/templates/Includes/`
To change the title of your widget, you need to override the Title() method. By default, this simply returns the $title To change the title of your widget, you need to override the Title() method. By default, this simply returns the $title
variable. For example, to set your widgets title to 'Hello World!', you could use: variable. For example, to set your widgets title to 'Hello World!', you could use:
**widgets_yourWidget/YourWidgetWidget.php** **widgets_yourWidget/src/YourWidgetWidget.php**
:::php ```php
public function Title() { public function Title()
return "Hello World!"; {
} return 'Hello World!';
}
```
but, you can do exactly the same by setting your `$title` variable.
but, you can do exactly the same by setting your $title variable.
A more common reason for overriding Title() is to allow the title to be set in the CMS. Say you had a text field in your A more common reason for overriding Title() is to allow the title to be set in the CMS. Say you had a text field in your
widget called WidgetTitle, that you wish to use as your title. If nothing is set, then you'll use your default title. widget called WidgetTitle, that you wish to use as your title. If nothing is set, then you'll use your default title.
This is similar to the RSS Widget in the blog module. This is similar to the RSS Widget in the blog module.
:::php ```php
public function Title() { public function Title()
return $this->WidgetTitle ? $this->WidgetTitle : self::$title; {
} return $this->WidgetTitle ? $this->WidgetTitle : self::$title;
}
```
This returns the value inputted in the CMS, if it's set or what is in the $title variable if it isn't. This returns the value inputted in the CMS, if it's set or what is in the $title variable if it isn't.
@ -263,69 +303,97 @@ sure that your controller follows the usual naming conventions, and it will be a
**mysite/code/MyWidget.php** **mysite/code/MyWidget.php**
:::php ```php
class MyWidget extends Widget { <?php
private static $db = array(
'TestValue' => 'Text'
);
}
class MyWidget_Controller extends WidgetController { namespace Yourname\MyWidget;
public function MyFormName() {
return new Form(
$this,
'MyFormName',
new FieldList(
new TextField('TestValue')
),
new FieldList(
new FormAction('doAction')
)
);
}
public function doAction($data, $form) { use SilverStripe\Widgets\Model\Widget;
// $this->widget points to the widget
}
}
class MyWidget extends Widget
{
private static $db = array(
'TestValue' => 'Text'
);
}
```
```php
<?php
namespace Yourname\MyWidget;
use SilverStripe\Widgets\Controllers\WidgetController;
use SilverStripe\Forms\Form;
use SilverStripe\Forms\FormAction;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
class MyWidgetController extends WidgetController
{
public function MyFormName()
{
return new Form(
$this,
'MyFormName',
new FieldList(
new TextField('TestValue')
),
new FieldList(
new FormAction('doAction')
)
);
}
public function doAction($data, $form)
{
// $this->widget points to the widget
}
}
```
To output this form, modify your widget template. To output this form, modify your widget template.
**mysite/templates/MyWidget.ss** **mysite/templates/Yourname/MyWidget/MyWidget.ss**
:::ss ```
$Content $Content
$MyFormName $MyFormName
```
**Note:** The necessary controller actions are only present in subclasses of `Page_Controller`. To use **Note:** The necessary controller actions are only present in subclasses of `PageController`. To use
widget forms in other controller subclasses, have a look at *ContentController->handleWidget()* and widget forms in other controller subclasses, have a look at `ContentController->handleWidget()` and
*ContentController::$url_handlers*. `ContentController::$url_handlers`.
## But what if I have widgets on my blog currently?? ## But what if I have widgets on my blog currently??
**Note:** This applies to old versions of the blog module. The latest version of this module does not contain `BlogHolder.php`.
If you currently have a blog installed, the widget fields are going to double up on those pages (as the blog extends the If you currently have a blog installed, the widget fields are going to double up on those pages (as the blog extends the
Page class). One way to fix this is to comment out line 30 in BlogHolder.php and remove the DB entry by running a Page class). One way to fix this is to comment out line 30 in `BlogHolder.php` and remove the DB entry by running a
`http://www.mysite.com/db/build`. `http://www.mysite.com/db/build`.
**blog/code/BlogHolder.php** **blog/code/BlogHolder.php**
:::php ```php
<?php <?php
class BlogHolder extends Page { class BlogHolder extends Page
{
........ // ........
static $has_one = array( static $has_one = array(
// "Sidebar" => "WidgetArea", COMMENT OUT // "Sidebar" => "WidgetArea", COMMENT OUT
'Newsletter' => 'NewsletterType' 'Newsletter' => 'NewsletterType'
....... );
public function getCMSFields() { // .......
$fields = parent::getCMSFields(); public function getCMSFields()
$fields->removeFieldFromTab("Root.Content","Content"); {
// $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("Sidebar")); COMMENT OUT $fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content","Content");
........ // $fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("Sidebar")); COMMENT OUT
}
// ...
}
```
Then you can use the Widget area you defined on Page.php Then you can use the Widget area you defined on Page.php
@ -339,4 +407,4 @@ and any new translations will be merged back to the project source code.
Please use [https://www.transifex.com/projects/p/silverstripe-widgets/](https://www.transifex.com/projects/p/silverstripe-widgets/) to contribute translations, Please use [https://www.transifex.com/projects/p/silverstripe-widgets/](https://www.transifex.com/projects/p/silverstripe-widgets/) to contribute translations,
rather than sending pull requests with YAML files. rather than sending pull requests with YAML files.
See the ["i18n" topic](https://docs.silverstripe.org/en/3.2/developer_guides/i18n/) on doc.silverstripe.org for more details. See the ["i18n" topic](https://docs.silverstripe.org/en/4/developer_guides/i18n/) on doc.silverstripe.org for more details.

View File

@ -0,0 +1 @@
<?php

View File

@ -1,22 +1,31 @@
{ {
"name": "silverstripe/widgets", "name": "silverstripe/widgets",
"description": "Widgets are small pieces of functionality such as showing the latest Comments or Flickr Photos. They normally display on the sidebar of your website.", "description": "Widgets are small pieces of functionality such as showing the latest Comments or Flickr Photos. They normally display on the sidebar of your website.",
"type": "silverstripe-module", "type": "silverstripe-module",
"keywords": ["silverstripe", "widgets", "blog"], "keywords": ["silverstripe", "widgets", "blog"],
"authors": [ "authors": [
{ {
"name": "Ingo Schommer", "name": "Ingo Schommer",
"email": "ingo@silverstripe.com" "email": "ingo@silverstripe.com"
} }
], ],
"require": { "require": {
"silverstripe/framework": "^4", "silverstripe/framework": "^4.0@dev",
"silverstripe/cms": "^4" "silverstripe/cms": "^4.0@dev"
}, },
"extra": { "require-dev": {
"branch-alias": { "phpunit/PHPUnit": "~4.8"
"dev-master": "2.0.x-dev" },
} "extra": {
}, "branch-alias": {
"license": "BSD-3-Clause" "dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"SilverStripe\\Widgets\\": "src/",
"SilverStripe\\Widgets\\Tests\\": "tests/",
}
},
"license": "BSD-3-Clause"
} }

View File

@ -4,7 +4,7 @@ Contributions are welcome! Create an issue, explaining a bug or proposal. Submit
## Releasing a widget ## Releasing a widget
Follow the [standard procedures defined for releasing a SilverStripe module](http://doc.silverstripe.org/framework/en/3.1/topics/module-development). Follow the [standard procedures defined for releasing a SilverStripe module](https://docs.silverstripe.org/en/4/developer_guides/extending/how_tos/publish_a_module).
Here is a composer template you can use. Here is a composer template you can use.
@ -36,6 +36,11 @@ You need to finish off / change:
], ],
"extra" : { "extra" : {
"installer-name": "widgets_" "installer-name": "widgets_"
},
"autoload": {
"psr-4": {
"Yourname\\MyWidget\\": "src/"
}
} }
} }
``` ```

View File

@ -12,7 +12,9 @@ You'll also need to run `dev/build`.
Install the module through [composer](http://getcomposer.org): Install the module through [composer](http://getcomposer.org):
composer require silverstripe/widgets ```sh
$ composer require silverstripe/widgets
```
Widgets are essentially database relations to other models, mostly page types. Widgets are essentially database relations to other models, mostly page types.
By default, they're not added to any of your own models. The easiest and most common By default, they're not added to any of your own models. The easiest and most common
@ -20,10 +22,11 @@ way to get started would be to create a single collection of widgets under the
name "SideBar" on your `Page` class. This is handled by an extension which you name "SideBar" on your `Page` class. This is handled by an extension which you
can enable through your `config.yml`: can enable through your `config.yml`:
:::yml ```yaml
Page: Page:
extensions: extensions:
- WidgetPageExtension - WidgetPageExtension
```
Run a `dev/build`, and adjust your templates to include the resulting sidebar view. Run a `dev/build`, and adjust your templates to include the resulting sidebar view.
The placeholder is called `$SideBarView`, and loops through all widgets assigned The placeholder is called `$SideBarView`, and loops through all widgets assigned
@ -31,7 +34,7 @@ to the current page.
Alternatively, you can add one or more widget collections to your own page types. Alternatively, you can add one or more widget collections to your own page types.
Here's an example on how to just add widgets to a `MyPage` type, and call it Here's an example on how to just add widgets to a `MyPage` type, and call it
`MyWidgetArea` instead. `MyWidgetArea` instead. Please ensure you add the correct namespaces for your module.
### Installing a widget ### Installing a widget
@ -56,18 +59,28 @@ e.g.
**mysite/code/Page.php** **mysite/code/Page.php**
class Page extends SiteTree { ```php
... <?php
private static $has_one = array(
"MyWidgetArea" => "WidgetArea",
);
public function getCMSFields() { use SilverStripe\CMS\Model\SiteTree;
$fields = parent::getCMSFields(); use SilverStripe\Widgets\Form\WidgetAreaEditor;
$fields->addFieldToTab("Root.Widgets", new WidgetAreaEditor("MyWidgetArea")); use SilverStripe\Widgets\Model\WidgetArea;
return $fields;
} class Page extends SiteTree
} {
// ...
private static $has_one = array(
'MyWidgetArea' => WidgetArea::class
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Widgets', new WidgetAreaEditor('MyWidgetArea'));
return $fields;
}
}
```
In this case, you need to alter your templates to include the `$MyWidgetArea` placeholder. In this case, you need to alter your templates to include the `$MyWidgetArea` placeholder.
@ -95,66 +108,86 @@ An example widget is below:
**FlickrWidget.php** **FlickrWidget.php**
:::php ```php
<?php <?php
class FlickrWidget extends Widget {
private static $db = array(
"User" => "Varchar",
"Photoset" => "Varchar",
"Tags" => "Varchar",
"NumberToShow" => "Int"
);
namespace Yourname\MyWidget;
private static $defaults = array( use FlickrService;
"NumberToShow" => 8 use SilverStripe\Widgets\Model\Widget;
); use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\NumericField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
private static $title = "Photos"; class FlickrWidget extends Widget
private static $cmsTitle = "Flickr Photos"; {
private static $description = "Shows flickr photos."; private static $db = array(
'User' => 'Varchar',
'Photoset' => 'Varchar',
'Tags' => 'Varchar',
'NumberToShow' => 'Int'
);
public function Photos() { private static $defaults = array(
Requirements::javascript(THIRDPARTY_DIR . "/prototype/prototype.js"); 'NumberToShow' => 8
Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/effects.js"); );
Requirements::javascript("mashups/javascript/lightbox.js");
Requirements::css("mashups/css/lightbox.css");
$flickr = new FlickrService(); private static $title = 'Photos';
if($this->Photoset == "") { private static $cmsTitle = 'Flickr Photos';
$photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1); private static $description = 'Shows flickr photos.';
} else {
$photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1);
}
$output = new ArrayList(); public function Photos()
foreach($photos->PhotoItems as $photo) { {
$output->push(new ArrayData(array( // You'll need to install these yourself
"Title" => $photo->title, Requirements::javascript(THIRDPARTY_DIR . '/prototype/prototype.js');
"Link" => "http://farm1.static.flickr.com/" . $photo->image_path .".jpg", Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/effects.js');
"Image" => "http://farm1.static.flickr.com/" .$photo->image_path. "_s.jpg" Requirements::javascript('mashups/javascript/lightbox.js');
))); Requirements::css('mashups/css/lightbox.css');
}
return $output;
}
public function getCMSFields() { $flickr = new FlickrService();
return new FieldList( if ($this->Photoset == '') {
new TextField("User", "User"), $photos = $flickr->getPhotos($this->Tags, $this->User, $this->NumberToShow, 1);
new TextField("PhotoSet", "Photo Set"), } else {
new TextField("Tags", "Tags"), $photos = $flickr->getPhotoSet($this->Photoset, $this->User, $this->NumberToShow, 1);
new NumericField("NumberToShow", "Number to Show") }
);
}
}
$output = new ArrayList();
foreach ($photos->PhotoItems as $photo) {
$output->push(
new ArrayData(
array(
'Title' => $photo->title,
'Link' => 'http://farm1.static.flickr.com/' . $photo->image_path .'.jpg',
'Image' => 'http://farm1.static.flickr.com/' .$photo->image_path. '_s.jpg'
)
)
);
}
return $output;
}
public function getCMSFields()
{
return new FieldList(
new TextField('User', 'User'),
new TextField('PhotoSet', 'Photo Set'),
new TextField('Tags', 'Tags'),
new NumericField('NumberToShow', 'Number to Show')
);
}
}
```
**FlickrWidget.ss** **FlickrWidget.ss**
:::ss ```
<% control Photos %> <% control Photos %>
<a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a> <a href="$Link" rel="lightbox" title="$Title"><img src="$Image" alt="$Title" /></a>
<% end_control %> <% end_control %>
```
## Limiting Allowed Widgets for a Pagetype ## Limiting Allowed Widgets for a Pagetype
@ -162,8 +195,15 @@ You can lock down a particular `WidgetAreaEditor` to only allow adding certain w
**GreatPage.php** **GreatPage.php**
:::php ```php
$fields->addFieldToTab( $fields->addFieldToTab(
'Root.Widgets', 'Root.Widgets',
new WidgetAreaEditor('PhenomenalWidgetArea', ['ParticularlyEpicWidget', 'LessGreatWidget']) new WidgetAreaEditor(
); 'PhenomenalWidgetArea',
[
'Fully\\Qualified\\ParticularlyEpicWidget',
'Yourname\\MyModule\\LessGreatWidget'
]
)
);
```

View File

@ -5,8 +5,8 @@ the sidebar of your website. To check out a what a [Widget](http://silverstripe.
[demo site](http://demo.silverstripe.org/) [demo site](http://demo.silverstripe.org/)
[![Build Status](http://img.shields.io/travis/silverstripe/silverstripe-widgets.svg?style=flat-square)](https://travis-ci.org/silverstripe/silverstripe-widgets) [![Build Status](http://img.shields.io/travis/silverstripe/silverstripe-widgets.svg?style=flat-square)](https://travis-ci.org/silverstripe/silverstripe-widgets)
[![Code Quality](http://img.shields.io/scrutinizer/g/silverstripe/silverstripe-widgets.svg?style=flat-square)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-widgets) [![Code Quality](http://img.shields.io/scrutinizer/g/silverstripe/silverstripe-widgets.svg?style=flat-square)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-widgets)
[![Version](http://img.shields.io/packagist/v/silverstripe/silverstripe-widgets.svg?style=flat-square)](https://packagist.org/packages/silverstripe/silverstripe-widgets) [![Version](http://img.shields.io/packagist/v/silverstripe/widgets.svg?style=flat-square)](https://packagist.org/packages/silverstripe/widgets)
[![License](http://img.shields.io/packagist/l/silverstripe/silverstripe-widgets.svg?style=flat-square)](LICENSE.md) [![License](http://img.shields.io/packagist/l/silverstripe/widgets.svg?style=flat-square)](LICENSE.md)
## Share Links ## Share Links