Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

Thumbnail DataObjectManager Image

Go to End

10 Posts   2865 Views


Community Member, 50 Posts

12 October 2010 at 8:28am

Edited: 12/10/2010 8:38am

Thanks for starting this topic back up dude. Although I am a little confused trying to resize the SloganImage and SloganBackground. I have tried the different options I can think of but am stuck now.

class Homepage extends Page {

static $singular_name = 'Homepage';
static $plural_name = 'Home';

static $has_many = array(
'Slogans' => 'Slogans'

static $has_one = array (
'Code' => 'Image'

static $icon = "cms/images/treeicons/home";

public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->removeFieldFromTab("Root.Content.Main", "Heading");
$fields->removeFieldFromTab("Root.Content.Main", "Graphic");
$fields->removeFieldFromTab("Root.Content.Main", "Content");
$fields->addFieldToTab("Root.Content.Main", new ImageField("Code"));
$fields->addFieldToTab("Root.Content.Slogans", new DataObjectManager(
'SloganText'=> 'Text',
'CSSid' => 'CSS ID',
'SloganImage' => 'Image',
'SloganBackground' => 'Background'
return $fields;

class Homepage_Controller extends Page_Controller {

function BlogArticles($num=5) {
$article = DataObject::get_one("BlogHolder");
return ($article) ? DataObject::get("BlogEntry", "ParentID = $article->ID", "Date DESC", "", $num) : false;

function ServicePages($num=10) {
$page = DataObject::get_one("ServicesPage");
return ($page) ? DataObject::get("ServicePage", "ParentID = $page->ID", "", "", $num) : false;

function AboutPage() {
return DataObject::get_one("AboutPage");


class Slogans extends DataObject {
static $db = array (
'SloganText' => 'Varchar(100)',
'CSSid' => 'Varchar(50)'
static $has_one = array (
'SloganImage' => 'Image',
'SloganBackground' => 'Image',
'Homepage' => 'Homepage'
public function getCMSFields_forPopup() {
return parent::getCMSFields();
public function getDOMThumbnail() {
if($i = $this->YourImage()) {
return $i->CroppedImage(50,50);
return false;

IF you can point me in the right direction or any of my other code I have done wrong. I'm still learning SS. Thanks Ben


Forum Moderator, 4102 Posts

12 October 2010 at 8:40am

Sure, no problem. I've actually debated adding a decorator to the DOM package that would give all DataObjects some of these useful methods. Sort of the way that Image comes with a stock CMSThumbnail() method.

That one bothers me, though, because it blurs the line between Sapphire and CMS.

SilverStripe tips, tutorials, screencasts and more:

Go to Top