Skip to content

Instantly share code, notes, and snippets.

<?php
class Page extends SiteTree {
private static $db = array(
'ShowInFooter' => 'Boolean'
);
private static $defaults = array(
'ShowInFooter' => 1
<?php
class SomeModelAdmin extends ModelAdmin {
private static $managed_models = array(
"MyDataObject"
);
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);
@lozcalver
lozcalver / DisallowedChildrenExtension.php
Last active August 29, 2015 14:15
SilverStripe Page::$disallowed_children
<?php
/**
* Implements "disallowed children" functionality for page classes. Usage:
* private static $disallowed_children = array(
* 'SomePageType',
* 'SomeOtherPageType'
* );
* Note: not fully tested (e.g. does this prevent changing parent in "Settings" tab?)
* @author Loz Calver <[email protected]>
LeftAndMain:
extra_requirements_javascript:
- mysite/js/myfile.js
<?php
class FixedCurrencyField extends CurrencyField {
/**
* @param mixed $val
* @return $this
*/
public function setValue($val) {
if( ! $val) $val = 0.00;
File:
allowed_extensions:
- 'svg'
<?php
class CarouselSlide extends DataObject {
private static $db = array(
'Title' => 'Varchar(255)',
'Description' => 'Text'
);
private static $has_one = array(
<?php
class Page extends SiteTree {
/**
* Return any event pages that are in this section.
* @param ArrayList|null $children
* @param ArrayList|null &$events
* @return ArrayList
*/
<?php
class LeftAndMainSiteTreeExtension extends Extension {
/**
* Fix for disappearing SiteTree.
* @see https://github.com/silverstripe/silverstripe-framework/issues/4137
* @see https://github.com/silverstripe/silverstripe-cms/issues/1135
* @param &$html
*/
<?php
class SomeModelAdmin extends ModelAdmin {
private static $managed_models = array(
"MyDataObject"
);
public function getEditForm($id = null, $fields = null) {
$form = parent::getEditForm($id, $fields);