My _config.php

On this page you can find an example of my default _config.php for fresh SilverStripe installs.

The main changes I make are an test to find out whether I'm running on my local development server or on the live server. This way I can keep the code the same, regardless on what server the code is running on. All dev options are enabled for the localhost and different administration email addresses are set.

The other major items I change is disabling the align buttons, as they don't seem to work properly. To make it easy for clients to align images and text I replace them with preset styles. I find that this allows better and easier alignment of images and text.

<?php

global $project;
$project = 'mysite';

global $databaseConfig;

// Create different settings for live and localhost servers
if ($_SERVER['SERVER_NAME'] == "localhost") {
    $databaseConfig = array(
        "type" => 'MySQLDatabase',
        "server" => 'localhost',
        "username" => '######',
        "password" => '######',
        "database" => '######',
        "path" => ''
    );
    Email::setAdminEmail("myemail@example.com");

    define('SS_ENVIRONMENT_TYPE', 'dev');
    SSViewer::set_source_file_comments(true);
    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    Director::set_environment_type("dev");

} else {
    $databaseConfig = array(
        "type" => 'MySQLDatabase',
        "server" => '######',
        "username" => '######',
        "password" => '######',
        "database" => '######',
        "path" => ''
    );
    Email::setAdminEmail("client@example.com");
}

MySQLDatabase::set_connection_charset('utf8');

SSViewer::set_theme('theme');

// Set the site locale
i18n::set_locale('en_GB');

// enable nested URLs for this site (e.g. page/sub-page/)
SiteTree::enable_nested_urls();

// Sort assets folders and files alphabetically
File::$default_sort = 'Name';
Folder::$default_sort = 'Name';
Image::$default_sort = 'Name';

// Remove justification buttons and replace with styles
HtmlEditorConfig::get('cms')->removeButtons('justifyleft');
HtmlEditorConfig::get('cms')->removeButtons('justifycenter');
HtmlEditorConfig::get('cms')->removeButtons('justifyright');
HtmlEditorConfig::get('cms')->removeButtons('justifyfull');
HtmlEditorConfig::get()->setOption('content_css',project().'/css/typography.css, '.project().'/css/layout.css');
HtmlEditorConfig::get('cms')->setOption('theme_advanced_styles', 'None=none;Image left=left;Image center=center;Image right=right;Image left alone=leftAlone;Image right alone=rightAlone;Clear line=clearBoth;Email address (anti spam)=email');

// Enable anti spam protection
MathSpamProtection::setEnabled();

// Enable comment moderation to battle spam
PageComment::enableModeration();

To enabled the advanced styles to work the following should be added to /themes/yourtheme/css/typography.css.

.typography .left {
    float: left;
    padding: 0.5em 1em 1em 0;
}

.typography .right {
    float: right;
    padding: 0.5em 0 1em 1em;
}

.typography .center {
    display : block;
    margin: 0 auto 0 auto;
    text-align: center;
}

.typography .leftAlone {
    float: left;
    margin-right: 100%;
}

.typography .rightAlone {
    float: right;
    margin-left: 100%;
}

.typography .clearBoth {
    clear: both;
}