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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

TRYING TO GET IMAGE GALERY DETAILS ON OTHER PAGE


Go to End


1010 Views

Avatar
servalman

Community Member, 211 Posts

2 April 2011 at 5:41am

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