Skip to content

Instantly share code, notes, and snippets.

/Slider.php Secret

Created August 18, 2013 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/714238c61a9c02f7c80a to your computer and use it in GitHub Desktop.
Save anonymous/714238c61a9c02f7c80a to your computer and use it in GitHub Desktop.
<?php
class Slider extends DataObject {
public static $db = array(
"Link" => "Text"
);
public static $has_one = array(
"Image" => "Image"
);
public static $searchable_fields = array(
"ID",
"Link"
);
public static $summary_fields = array(
"TinyThumbnail" => "Image",
"Sorting",
"Title",
"Link"
);
public function getTitle() {
if(($image = $this->Image()) && $image->exists())
return $image->Title;
return $this->ID;
}
public function getTinyThumbnail() {
return $this->Image()->CroppedImage(50, 50);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment