Create a simple Silverstripe Module

Create a simple custom PageType that holds Addresses as DataObjects.


Three Files only

  • Adress.php
  • Addressage.php


Lets start!

1. Custom Dataobject

Let's assume we want to have an Address Database

ToDo: Sorry this is a draft.

2. Custom Page Type

A custom Page Type can automatically be choosen in the Admin via "Add New".

namespace {

use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;

  class AddressPage extends Page
    // Datenbankfelder
    private static $db = [
    private static $defaults = [

    private static $has_one = [];
    // This Page has multiple Address-DataObjects, accessible under the Name "Adresses"
    private static $has_many = [
      'Adresses' => 'Address'
    // Edit-Felder im Backend
    public function getCMSFields() {
      $fields = parent::getCMSFields(); // Alle Felder des Mutter-Pagetyps inkludieren

    // Spezielles GridField zur Admin Oberfläche hinzufügen
    $fields->addFieldToTab('Root.Adressen', GridField::create(

    return $fields;


3. Template it

This is connected trough simple Naming Convention.
If your custom PageType is AddressPage, the Template for it has to be named

Create Template inside templates....

<div id="AddressDatabase">

<% loop Adresses %>


<% end_loop%>