Skip to content

Instantly share code, notes, and snippets.

View muskie9's full-sized avatar

Nic muskie9

View GitHub Profile
var $mycolumns = $('.casestudies .study');
var height = 0;
$mycolumns.each(function () {
if ($(this).height() > height) {
height = $(this).height();
}
});
$mycolumns.height(height);
<?php
public function ProductTypeBrands(){
//list to return
$brands = ArrayList::create();
$addToBrands = function($product) use (&$brands){
if(!$brands->find($product->BrandID)){
$brands->push($Product->Brand());//Assuming the relation name for the has_one is Brand
}
<?php
public function CurrentLevel() {
$page = $this->owner;
$level = 1;
while(1) {
if($page->Parent) {
$level++;
$page = $page->Parent();
}else {
(function($) {
$(.cms-container).entwine(function($) {
onmatch: function(){
alert('Yay!!!');
}
});
});
<?php
class MyUserForm extends UserDefinedForm{
private static $db = array(
'Template' => 'Enum("Template1","Template2","Template3")'
);
public funciton getCMSFields(){
$fields = parent::getCMSFields();
<?php
public function validate()
{
$result = parent::validate();
if($this->MyImage()->getWidth() < 100 || $this->MyImage()->getHeight() < 100) {
$result->error('Need a larger image');
}
<?php
class MyPage extends Page{
}
class MyPage_Controller extends Page_Controller{
private static $allowed_actions = array();
<?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')){
<?php
class MyObject extends DataObject{
private static $has_one = array(
'Image' => 'Image'
);
public function getOriginalImage(){
return $this->Image();
jQuery(document).ready(function(){
jQuery.each('.same', function(index){
var newClass = 'extra' + index;
jQuery(this).addClass(newClass);
});
});