This document contains information for an outdated version (2.4) and may not be maintained any more. If some of your projects still use this version, consider upgrading as soon as possible.



LeftAndMain is the base class of all the admin area controllers.

Best Practices


Please use LeftAndMain::ForceReload to reload the whole form-area after an Ajax-Request. If you just need to refresh parts of the form, please use javascript-replacement in the response of the original Ajax-Request. Consider using Form for compiling Ajax-Responses and automatic detection of Ajax/Non-Ajax-Calls.

Custom Access Checking

You can customize access control in LeftAndMain.

// mysite/_config.php

// MyLeftAndMain.php
class MyLeftAndMain extends Extension {
  function augumentInit() {
    // add custom requirements etc.
  function alternateAccessCheck() {
    // custom permission checks, e.g. to check for an SSL-connection, or an LDAP-group-membership


There are a few steps in creating a subclass of LeftAndMain.


The PHP file defining your new subclass is the first step in the process. This provides a good starting point:

class MyAdmin extends LeftAndMain {

    static $url_segment = 'myadmin';

    static $url_rule = '$Action/$ID';

    static $menu_title = 'My Admin';

    static $menu_priority = 60;


     * Initialisation method called before accessing any functionality that BulkLoaderAdmin has to offer
    public function init() {



     * Form that will be shown when we open one of the items
    public function getEditForm($id = null) {
        return new Form($this, "EditForm",
            new FieldSet(
                new ReadonlyField('id #',$id)
            new FieldSet(
                new FormAction('go')


Next, create templates, (classname) and (classname) Again, here are a couple of starting points:

  • On the left, we're using the tree as a way of providing navigation. The left and side could be replaced with anything but LeftAndMain has built-in support for trees.
  • On the right, we have the skeleton that the form will be loaded into.

<div class="title"><div>Functions</div></div>

<div id="treepanes">
<div id="sitetree_holder" style="overflow:auto">
    <% if Items %>
        <ul id="sitetree" class="tree unformatted">
        <li id="$ID" class="root Root"><a>Items</a>
            <% control Items %>
                <li id="record-$class">
                <a href="admin/my/show/$ID">$Title</a>
            <% end_control %>
    <% end_if %>

<div class="title"><div>My admin</div></div>

<% if EditForm %>
<% else %>
    <form id="Form_EditForm" action="admin/my?executeForm=EditForm" method="post" enctype="multipart/form-data">
        <p>Welcome to my $ApplicationName admin section.  Please choose something from the left.</p>
<% end_if %>

<p id="statusMessage" style="visibility:hidden"></p>

Customising the main menu

Minimum Requirement: Silverstripe 2.3

The static variable $url_segment determines the sub url of the controller. The static variable $url_rule has the url format for the actions performed by the class. The static variable $menu_title is the title of the administration panel in the menu. The static variable $menu_priority tells the CMS where to put the menu item relative to other panels.

For example:

static $url_segment = 'myadmin';
static $url_rule = '$Action/$ID';
static $menu_title = 'My Admin';
static $menu_priority = 60;

See also CMSMenu

Translatable Menu Titles

Override the function getMenuTitle() to create a translated menu title name. Eg:

public function getMenuTitle() {
   return _t('LeftAndMain.MYADMIN', 'My Admin', PR_HIGH, 'Menu title');

'onload' javascript in the CMS

You can have custom scripting called when a Page is loaded by clicking on the Site Content Tree. This can be used to set up event handlers, or populate dropdowns, etc. You could insert this code using Requirements from a custom page class.

    '#Form_EditForm' : {
        initialize : function() {
            this.observeMethod('PageLoaded', this.adminPageHandler);
        adminPageHandler : function() {
            // Place your custom code here.

See Javascript in the CMS


  • Explain how to build the javascript file
  • Explain how the ajax button handlers work
  • Explain how to create little pop-up dialogs