This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MaxWidthHeightImageExtension extends DataExtension { | |
/** | |
* Crop an image if it exceeds a certain height. | |
* Use in templates e.g. $Image.SetWidth(200).MaxHeight(200) | |
* | |
* @param integer $maxHeight Max height of image | |
* @return Image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ko_KR: | |
Header: | |
LANGUAGE_LABEL: '언어' | |
Footer: | |
SITEMAP_LABEL: '사이트맵' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
class MyDataObject extends DataObject { | |
private static $db = [ | |
'FoobarCountryCode' => 'Varchar', | |
'FoobarAreaCode' => 'Varchar', | |
'FoobarPhoneNumber' => 'Varchar', | |
'FoobarExtension' => 'Varchar', | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
var clonePriorTimes = function (button) { | |
var toCopy = button.attr('name'); | |
console.log(toCopy); | |
}; | |
$('.cms-edit-form .field.can-copy .ui-button').entwine({ | |
onclick: function () { | |
clonePriorTimes(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function getEditForm($id = null, $fields = null) { | |
$form = parent::getEditForm($id, $fields); | |
// $gridFieldName is generated from the ModelClass, eg if the Class 'Product' | |
// is managed by this ModelAdmin, the GridField for it will also be named 'Product' | |
$gridFieldName = $this->sanitiseClassName($this->modelClass); | |
if($gridFieldName=='Speaker'){ | |
$gridField = $form->Fields()->fieldByName($gridFieldName); | |
$gridField->getConfig()->addComponent(new GridFieldOrderableRows()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function(){ | |
jQuery.each('.same', function(index){ | |
var newClass = 'extra' + index; | |
jQuery(this).addClass(newClass); | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyObject extends DataObject{ | |
private static $has_one = array( | |
'Image' => 'Image' | |
); | |
public function getOriginalImage(){ | |
return $this->Image(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyClass extends Page{ | |
public static function getFilteredList(SS_HTTPRequest $request = null){ | |
//assume the request var holds a valid SS_HTTPRequest | |
$list = MyObject::get(); | |
if($someVar = $request->getVar('Somevar')){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyPage extends Page{ | |
} | |
class MyPage_Controller extends Page_Controller{ | |
private static $allowed_actions = array(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function validate() | |
{ | |
$result = parent::validate(); | |
if($this->MyImage()->getWidth() < 100 || $this->MyImage()->getHeight() < 100) { | |
$result->error('Need a larger image'); | |
} |