PHPackages                             arillo/silverstripe-elements - 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. arillo/silverstripe-elements

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

arillo/silverstripe-elements
============================

Elements

3.0.6(2mo ago)53.7k↓33.3%1[11 issues](https://github.com/arillo/silverstripe-elements/issues)1MITHTMLCI failing

Since Jan 6Pushed 2mo ago6 watchersCompare

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

READMEChangelogDependencies (6)Versions (74)Used By (1)

SilverStripe Elements
=====================

[](#silverstripe-elements)

[![Latest Stable Version](https://camo.githubusercontent.com/61763cc19b2ec45f852844365f017068be5f096127250e82987242e1f6389786/68747470733a2f2f706f7365722e707567782e6f72672f6172696c6c6f2f73696c7665727374726970652d656c656d656e74732f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/arillo/silverstripe-elements) [![Total Downloads](https://camo.githubusercontent.com/4bd76e369e9e8ce4c1b9c3a3c23ee2d60da15225128a094f8f147002f395a0bc/68747470733a2f2f706f7365722e707567782e6f72672f6172696c6c6f2f73696c7665727374726970652d656c656d656e74732f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/arillo/silverstripe-elements)

Decorates a SiteTree class with multiple named element relations through a has\_many "Elements" relation.

### Requirements

[](#requirements)

SilverStripe CMS ^4.0

For a SilverStripe 3.x compatible version of this module, please see the [1 branch, or 0.x release line](https://github.com/arillo/silverstripe-elements/tree/1.x).

### Todo

[](#todo)

- write tests
- write better docs

### Usage

[](#usage)

Set up you relation types in your \_config/elements.yml, e.g:

```
Page:
  element_relations:
    Elements:
      - Element
      - DownloadElement
    Downloads:
      - DownloadElement
```

In this example we are creating 2 element relationships to the Page, one called Elements, the other called Downloads.

To make it work `Element` class should subclass `ElementBase`, where all additional fields can be defined, e.g.:

```
class Element extends ElementBase
{
    private static
        $singular_name = 'Base element',
        $db = [
            'Title' => 'Text',
            'Subtitle' => 'Text',
            ...
            ..
            .
        ]
    ;
}
```

In the SiteTree instance the element relations are now accessable through:

```
$pageInst->ElementsByRelation('Elements');
$elementInst->ElementsByRelation('Elements');
```

To use them in a template:

```
 $Render($Pos, $First, $Last, $EvenOdd)

```

**Notice:** we pass in the $Pos, $First, $Last and $EvenOdd values to have them available inside the template as $IsPos, $IsFirst, $IsLast and $IsEvenOdd.

There is also a helper function to move a gridfield into another tab if you prefer:

```
public function getCMSFields()
{
    $fields = parent::getCMSFields();
    // move the elements gridfield to a tab called 'PageElements'..
    $fields = ElementsExtension::move_elements_manager($fields, 'Elements', 'Root.PageElements');
    return $fields;
}
```

### Nested Element relations

[](#nested-element-relations)

Apply the same extension to the Element instead of the Page.

```
TeasersElement:
  element_relations:
    Teasers:
      - TeaserElement
```

### Element inheritance

[](#element-inheritance)

If you would like to have the same elements applied to different Pagetypes you can use the `element_relations_inherit_from` definition referencing a arbitrary setup in the yml file. For example if we want the HomePage and the EventsPage to inherit the same elements we can define the .yml like this:

```
HomePage:
  element_relations_inherit_from: MainElements
EventsPage:
  element_relations_inherit_from: MainElements
```

They both reference the MainElements defined in the yml where you have defined the element\_relations, like this:

```
MainElements:
  element_relations:
    Elements:
      - HeroElement
      - DownloadElement
      - TeasersElement
```

If you inherit elements you can still create your custom relations and also append new Element types to the inherited relation.

```
HomePage:
  element_relations_inherit_from: MainElements
  element_relations:
    Elements:
      - ImageElement
```

In this example ImageElement is added to the list of available Elements defined in MainElements.

### URLSegmentField

[](#urlsegmentfield)

If you want to show the URLSegment field in the cms, you can opt-in via the config show\_urlsegment\_field

```
ElementBase:
  show_urlsegment_field: true
```

### Bulkuploader

[](#bulkuploader)

There is support for using `Colymba\BulkUpload\BulkUploader` for an relation to a single element. E.g. given the following relation:

```
ImagesElement:
  element_relations:
    Images:
      - ImageElement # an element with a has_one Image (Image) relation
```

you can apply a bulkuploader in `ImagesElement`:

```
use Arillo\Elements\BulkUploader;

public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        if ($images = $fields->dataFieldByName('Images')) {
            BulkUploader::apply(
                $images,
                [
                    BulkUploader::ELEMENT_CLASSNAME => ImageElement::class,
                    BulkUploader::ELEMENT_RELATIONNAME => 'Images',
                    BulkUploader::FOLDER_NAME => 'FancyFolderName', // optional
                    BulkUploader::FILE_RELATIONNAME => 'File',  // optional, may be mandatory if you element has multiple has_one file relations
                ]
            );
        }
        return $fields;
    }
```

### Translation

[](#translation)

Naming of `Tab` and `GridField` labels can be done through silverstripes i18n. There is a special key called `Element_Relations` reserved to accomplish this task, e.g. in de.yml:

```
de:
  Element_Relations:
    Downloads: "Dateien"
```

### Populate default elements

[](#populate-default-elements)

A button below the Element GridField called "Create default elements" will populate the default elements defined in your \_config.yml as empty elements in your page. If you trigger the action again it will counter-check against the already created elements and don't add any duplicates.

You can define the element\_defaults for each of your relations like this:

```
Page:
  element_relations:
    Teasers:
      - TeaserElement
  element_defaults:
    Teasers:
      - TeaserElement
```

### Fluent integration

[](#fluent-integration)

To use fluent with elements just add the Fluent extensions to the ElementBase:

```
Arillo\Elements\ElementBase:
  extensions:
    - 'TractorCow\Fluent\Extension\FluentVersionedExtension'
    - 'TractorCow\Fluent\Extension\FluentFilteredExtension'
```

### Options

[](#options)

Use a tab instead of inline field when only one relation available

```
Arillo\Elements\ElementsExtension:
  use_custom_tab: true
```

Changelog:
----------

[](#changelog)

### 2.2.5

[](#225)

- removed fluent records auto-deletion

### 2.1.9

[](#219)

– added support for SS 4.4 GridFieldDetailForm::setShowAdd – removed 'onAfterDelete' hook, if you need auto deletion, add:

```
Arillo\Elements\ElementsExtension:
  cascade_deletes:
    - Elements

```

### 2.1.8

[](#218)

- addded support for bulkuploading

### 2.1.0

[](#210)

- removed Fluent Locales auto-creation, use [`Arillo\Utils\FluentFilteredHelper`](https://github.com/arillo/silverstripe-utils/blob/master/src/FluentFilteredHelper.php) instead.
- refactor GridField overview display: added `getCMSTypeInfo` and `getCMSSummary` functions.

### 2.0.0

[](#200)

- SilverStripe 4 compat

### 0.2.0

[](#020)

- remove DefaultElementsExtension
- add Publish page button in Element DetailForm

### 0.1.0

[](#010)

- remove extensions from your mysite/\_config/elements.yml

```
ElementBase:
  extensions:
    - arillo\elements\ElementsExtension

Page:
  extensions:
    - arillo\elements\ElementsExtension
```

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance67

Regular maintenance activity

Popularity25

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 53% 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 ~48 days

Recently: every ~84 days

Total

71

Last Release

63d ago

Major Versions

0.2.7 → 1.1.x-dev2018-10-20

1.1.x-dev → 2.0.62018-12-18

1.2.1 → 2.2.12019-11-28

2.x-dev → 3.0.12025-03-20

3.0.5 → 6.x-dev2026-02-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/c08728a857fbe8bcf6f7583d48a343743383d599d62357bba253755a06a85b69?d=identicon)[banglashi](/maintainers/banglashi)

![](https://avatars.githubusercontent.com/u/942999?v=4)[Arillo](/maintainers/Arillo)[@arillo](https://github.com/arillo)

---

Top Contributors

[![bumbus](https://avatars.githubusercontent.com/u/1391103?v=4)](https://github.com/bumbus "bumbus (79 commits)")[![banglashi](https://avatars.githubusercontent.com/u/942981?v=4)](https://github.com/banglashi "banglashi (68 commits)")[![nicolas-cusan](https://avatars.githubusercontent.com/u/1353931?v=4)](https://github.com/nicolas-cusan "nicolas-cusan (2 commits)")

---

Tags

phpsilverstripesilverstripe-elementssilverstripeelements

### Embed Badge

![Health badge](/badges/arillo-silverstripe-elements/health.svg)

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

###  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.0M72](/packages/silverstripe-userforms)[silverstripe/comments

Provides commenting functionality for your SilverStripe site.

41256.1k13](/packages/silverstripe-comments)[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)
