Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » TRYING TO GET IMAGE GALERY DETAILS ON OTHER PAGE

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 570 Views
  • servalman
    Avatar
    Community Member
    211 Posts

    TRYING TO GET IMAGE GALERY DETAILS ON OTHER PAGE Link to this post

    Hello

    This what I'm trying to do :

    I have extended ImageGalleryPage to add more details to it like this

    in code/MyImageGalleryItem.php

    <?php
    class MyImageGalleryItem extends ImageGalleryItem
    {
    static $db = array (
    'Title' => 'Varchar(100)',
    'Day' => 'Varchar(50)',
    'Edition' => 'Varchar(50)',
    'Technique' => 'Varchar(50)' ,
    'Dimensions' => 'Varchar(100)',
    'Original' => 'Varchar(50)' ,
    'TechniqueOriginal' => 'Varchar(50)' ,
    'DimensionsOriginal' => 'Varchar(100)',
    'Sold' => 'Boolean'
    // etc...
    );

    public function getCMSFields_forPopup()
    {
    $f = parent::getCMSFields_forPopup();
    $f->push(new TextField('Title','Tiltle'));
    $f->push(new TextField('Day','Day'));
    $f->push(new TextField('Edition','Edition'));
    $f->push(new TextField('Technique','Technique'));
    $f->push(new TextField('Dimensions','Dimensions'));
    $f->push(new TextField('Original','Original'));
    $f->push(new TextField('TechniqueOriginal','TechniqueOriginal'));
    $f->push(new TextField('DimensionsOriginal','DimensionsOriginal'));
    $f->push(new CheckboxField('Sold','This painting is sold'));
    return $f;
    }
    }

    in code/MyImageGalleryPage.php

    <?php
    class MyImageGalleryPage extends ImageGalleryPage {
    protected $itemClass = "MyImageGalleryItem";
    }

    class MyImageGalleryPage_Controller extends ImageGalleryPage_Controller {

    }
    ?>

    Now I'm trying to display some of the information for example Dimensions or Edition in an other page

    I then created another page code/DimensionPage.php with this

    <?php
    /**
    * Defines the WordPage page type
    */
    class DimensionPage extends Page {
    static $db = array(
    );
    static $has_one = array(
    );
    }

    class DimensionPage_Controller extends Page_Controller {

       function getWords() {
    $words = DataObject::get("MyImageGalleryItem","$Dimension");
    }
    }

    ?>

    but of course it is not working because I don't really understand how DataObject::get works works even tough I've been reading docs
    I'm pretty new to all this so if someone can take a bit of time to explain or point a relevant post it would be great

    Thanks

    570 Views
Page: 1
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.