PHPackages                             plato-creative/sections - 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. plato-creative/sections

ActiveLibrary

plato-creative/sections
=======================

Sections

1.0.1(7y ago)0348↓75%BSD-3-ClausePHP

Since Jul 26Pushed 2y ago2 watchersCompare

[ Source](https://github.com/PlatoCreative/sections)[ Packagist](https://packagist.org/packages/plato-creative/sections)[ Docs](http://github.com/plato-creative/sections)[ RSS](/packages/plato-creative-sections/feed)WikiDiscussions master Synced 3d ago

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

Sections
========

[](#sections)

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

[](#installation)

Composer is the recommended way of installing SilverStripe modules.

```
composer require plato-creative/sections

```

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

[](#requirements)

- silverstripe/cms ^4.0

Maintainers
-----------

[](#maintainers)

- [Plato Creative](web@platocreative.co.nz)

Documentation
-------------

[](#documentation)

### Add sections to a page

[](#add-sections-to-a-page)

#### Standard section area

[](#standard-section-area)

Add a sections area to a page type.

```
class MyCustomPage extends Page
{
    private static $extensions = array(
        'Sectioned'
    )
}
```

By default this will add a sections area that can be accessed via page templates with `{$Area}`

#### Multiple section areas

[](#multiple-section-areas)

To add multiple sections to a page type.

```
class MyCustomPage extends Page
{
    private static $extensions = array(
        'Sectioned'
    )

    private static $areas = array(
        'Sections' => 'Sections' // make sure you add standard sections area in other it will be deleted
        'OtherSections' => 'Other sections cms title'
    )
}
```

This can be accessed in the page template with:

```

    {$Area}

    {$Area('OtherSections')}

```

#### Limit section types by page type

[](#limit-section-types-by-page-type)

Set allowed sections.

```
class MyCustomPage extends Page
{
    private static $extensions = array(
        'Sectioned'
    )

    private static $allowed_sections = array(
        'ContentSection',
        'BannerSection'
    )
}
```

Set excluded sections.

```
class MyCustomPage extends Page
{
    private static $extensions = array(
        'Sectioned'
    )

    private static $exclude_sections = array(
        'FormSection'
    )
}
```

### Create new section types

[](#create-new-section-types)

```
class MyCustomSection extends Section
{
    // Defines the name used in the cms such as a new dropdown and gridfield type.
    private static $singular_name = 'My custom name';
    private static $plural_name = 'Sections';

    // Define db fields
    private static $db = array(
        'Content' => 'HTMLText'
    );

    // Define a list db fields that can be searched via the frontend
    private static $site_searchable_fields = array(
        'Content'
    );

    // Defines available layouts for this section selectable in the cms
    private static $layouts = array(
        'left-text' => 'Left text',
        'right-text' => 'Right text',
        'center' => 'Center',
    );

    // Defines available color schemes for this section selectable in the cms
    private static $colors = array(
        'black' => 'White text on black',
        'blue' => 'White text on blue background'
    );

    // Defines a custom css class for this section
    private static $base_class = 'my-custom-css-class';

    // Defines if the title of the section will be forced to hide from public display.
    private static $title_force_hide = true;

    public function getCMSFields()
    {
        $fields = parent::getCMSFields(); // This is required as sections will add its own fields
        $fields->addFieldsToTab(
            "Root.Main",
            array(
                HTMLEditorField::create(
                    'Content',
                    'Content'
                )
            )
        );
        $this->extend('updateCMSFields', $fields);
        return $fields;
    }
}
```

### Add a custom form to a section controller

[](#add-a-custom-form-to-a-section-controller)

```
class MyCustomSectionController extends SectionController
{
    private static $allowed_actions = array(
        'Form'
    );

    public function Form(){
        $fields = FieldList::create(array(
            TextField::create('Name'),
            EmailField::create('Email'),
            TextField::create('Phone'),
            TextAreaField::create('Message')
        ));
        $actions = FieldList::create(
            FormAction::create('submit', 'Send Enquiry')
        );
        return Form::create($this, 'Form', $fields, $actions);
    }

    public function submit($data, $form){
        // process form data as usual
        // ...
        // redirect
        return $this->redirect($this->CurrentPage->Link() . '?contacted=1');
    }
}
```

### Templating

[](#templating)

#### File names

[](#file-names)

Sections will look for the template based on the section section name in you theme template directory. e.g. MyCustomSection will look for MyCustomSection.ss.

In addition sections will look for templates that have a specific layout appended to it. e.g. MyCustomSection\_left-text.ss

Sections will also look for templates that are specific to a page type. e.g. MyCustomSection\_homepage.ss

Finally sections will look for templates that match both specific layout and page type. e.g. MyCustomSection\_homepage\_left-text.ss

##### Filename hierarchy example

[](#filename-hierarchy-example)

Taking the following conditions page classname = HomePage, section classname = MyCustomSection, section layout = left-text and extends MyParentSection we can see the templates that are searched and their priority from first to last.

```
MyCustomSection_homepage_left-text.ss // If not found then find next template.
MyCustomSection_left-text.ss // If not found then find next template.
MyCustomSection_homepage.ss // If not found then find next template.
MyCustomSection.ss // If not found then find next template.
MyParentSection_homepage_left-text.ss // If not found then find next template.
MyParentSection_left-text.ss // If not found then find next template.
MyParentSection_homepage.ss // If not found then find next template.
MyParentSection.ss // If not found then find next template.
Section.ss // Base template.  // If not found then error out.

```

#### Sections template variables

[](#sections-template-variables)

Sections has a few useful variables to help.

`{$Class}`: Returns the class defined by the section object or layout it may have.

```
mycustomsection

```

`{$ClassAttr}`: Returns a class attribute with the class of the section.

```
class="mycustomsection"

```

`{$Color}`: Returns color defined by the section object.

`{$Anchor}`: Returns a html safe string based on the title of the current section.

```
check-out-our-features

```

`{$AnchorAttr}` or `{$TargetAttr}`: Returns a id attribute based on the title of the current section.

```
id="check-out-our-features"

```

`{$Pos}` The current integer position in the area. Will start at 1.

`{$Even}`, `{$Odd}`, `{$First}`, `{$Last}` or `{$Middle}`: Booleans about the position in the area.

`{$CurrentPage}`: Access the current page scope.

```
{$CurrentPage.Title}

    {$Title} - {$Link}

```

#### Section template title

[](#section-template-title)

By default `$Title` in sections uses [HTMLTag](https://github.com/gorriecoe/silverstripe-htmltag) to wrap a tag with html defined in the cms. So your template can simplified to this.

```
{$Title}

```

Is the equivalent of

```

        {$Title}

```

And returns

```

    This sections title

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 57.1% 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 ~1018 days

Total

3

Last Release

812d ago

Major Versions

1.0.1 → v5.x-dev2024-02-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/23e3a1ee967f8874e7e6bdc6394b03876b07e281c437c2fc40113e7a01b83878?d=identicon)[platocreative](/maintainers/platocreative)

---

Top Contributors

[![dawb](https://avatars.githubusercontent.com/u/777930?v=4)](https://github.com/dawb "dawb (4 commits)")[![gorriecoe](https://avatars.githubusercontent.com/u/11811440?v=4)](https://github.com/gorriecoe "gorriecoe (3 commits)")

### Embed Badge

![Health badge](/badges/plato-creative-sections/health.svg)

```
[![Health](https://phpackages.com/badges/plato-creative-sections/health.svg)](https://phpackages.com/packages/plato-creative-sections)
```

###  Alternatives

[silvershop/core

Provides an ecommerce product catalog, shopping cart, and order management system

11340.0k42](/packages/silvershop-core)[silverstripe-terraformers/gridfield-rich-filter-header

Rich filter header component for GridField

1325.7k1](/packages/silverstripe-terraformers-gridfield-rich-filter-header)[sunnysideup/ecommerce

Silverstripe E-commerce Application

257.2k79](/packages/sunnysideup-ecommerce)[silverstripe/superglue

102.2k](/packages/silverstripe-superglue)

PHPackages © 2026

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