Silverstripe _config.php Cheatsheet

Here are some of most used lines in _config.php:

/**********************
 *
 * Errors / Dev
 *
 **********************/
//
//Force enviroment to Dev ** REMOVE FOR LIVE SITES **
Director::set_environment_type("dev");
//
//Force cache to flush on page load if in Dev mode (prevents needing ?flush=1 on the end of a URL)
if (Director::isDev()) {
    SSViewer::flush_template_cache();
}
//(v2.4) Log errors to an email address
SS_Log::add_writer(new SS_LogEmailWriter('me@mydomain.com'), SS_Log::ERR);
//
//(v2.4) Log errors to a file
SS_Log::add_writer(new SS_LogFileWriter('error_log.txt'), SS_Log::ERR);
//
/**********************
 *
 * CMS Rebranding
 *
 **********************/
//
//Set the CMS application name, logo and loading image
LeftAndMain::setApplicationName("My application");
LeftAndMain::setLogo("themes/MyTheme/images/CMSLogo.png", "margin-top: -3px;");
LeftAndMain::set_loading_image('themes/MyTheme/images/CMSLoading.gif');
//
/**********************
 *
 * Security
 *
 **********************/
//
//Set default login
Security::setDefaultAdmin('admin','pass');
//
//Define the password validator
$pwdValidator = new PasswordValidator();
$pwdValidator->minLength(8);
$pwdValidator->checkHistoricalPasswords(2);
$pwdValidator->characterStrength(2,array('lowercase','digits'));
Member::set_password_validator($pwdValidator);
//
// Set the site locale
i18n::set_locale('en_UK');
//
/**********************
 *
 * Templates / ULRs
 *
 **********************/
//
//Remove Prototype / Behaviour validation and use your own
Validator::set_javascript_validation_handler('none');
//
// Set the theme
SSViewer::set_theme('FBO');
//Enable Search, use $SearchForm in template
FulltextSearchable::enable();
//
//Turn off # link rewriting
SSViewer::setOption('rewriteHashlinks', false);
//
//Force redirect to www.
Director::forceWWW();
//
//(v2.4) enable nested URLs for this site (e.g. page/sub-page/)
SiteTree::enable_nested_urls();
//
// Set the Breadcrumb divider
SiteTree::$breadcrumbs_delimiter = " >> ";
//
// Set the resizing image quality
GD::set_default_quality(95);
//
/**********************
 *
 * CMS UI
 *
 **********************/
//
//Hide a main CMS Tab
CMSMenu::remove_menu_item('CommentAdmin');
//
//Make a data objects sortable (for DOM)
SortableDataObject::add_sortable_classes(array(
        'DataObject',
        'AnotherDataObject'
));
//
//Set HTML EDitor Config
HtmlEditorConfig::get('cms')->setOption('convert_fonts_to_spans', false);
//
HtmlEditorConfig::get('cms')->enablePlugins('searchreplace');
//
HtmlEditorConfig::get('cms')->insertButtonsAfter('pasteword', 'replace');
//
HtmlEditorConfig::get('cms')->setOptions(array( 'content_css' => 'static/css/editor.css' ));
//
//Add requirments to the CMS
LeftAndMain::require_javascript('mysite/javascript/jquery.cms.js');
//
LeftAndMain::require_css('themes/mytheme/css/cms.css');
//
/**********************
 *
 * Classes / Objects
 *
 **********************/
//
//Add an extention to an object and DataObject
Object::add_extension('SiteConfig', 'CustomSiteConfig');
DataObject::add_extension('DataObject', 'DataObjectExtension');
//
// Use a custom class instead of a core one
Object::useCustomClass('MemberLoginForm', 'CustomLoginForm');
//
//Set allowed file types
File::$allowed_extensions[] = "f4v";
//
/**********************
 *
 * Emails
 *
 **********************/
//
//Set the admin email address
Email::setAdminEmail('me@mydomain.com');
//
//Set to CC all emails to
Email::cc_all_emails_to('me@mydomain.com');
//
/**********************
 *
 * Comments
 *
 **********************/
//
//Enable comment spam protection
MathSpamProtection::setEnabled();
//
//Enable comment moderation
PageComment::enableModeration();
//
//Force user to be logged in to post a comment
PageCommentInterface::set_comments_require_login(true);

Looking for quality SilverStripe Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , | Posted under SilverStripe CMS | RSS 2.0

Author Spotlight

Teet Bergmann

Teet Bergmann

I'm a freelance web designer from Estonia. Mostly doing sites using Silverstripe, magento, prestashop, wordpress.

Leave a Reply

Your email address will not be published. Required fields are marked *


2 − = 1

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>