Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Thumbnail DataObjectManager Image

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 2184 Views
  • web2works
    Community Member
    50 Posts

    Re: Thumbnail DataObjectManager Image Link to this post

    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

  • UncleCheese
    4085 Posts

    Re: Thumbnail DataObjectManager Image Link to this post

    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: http://www.leftandmain.com

Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.