Ok.. So I built the pagetype ProjectHOlder who is supposed to have many projects and under the Project Page a lot of images( different for each project).
The problem is that when I go to the CMS it shows up the images from my slideshow on the homepage. I copied and pasted the code from my slideshow and renamed the classes to ProjectPage
<?php
// /mysite/code/GalleryPage.php
class ProjectPage extends Page
{
static $has_many = array (
'Images' => 'ImageResource'
);
public static $db = array(
'YoutubeURL'=>'Text'
);
public static $has_one = array('Before'=>'Image', 'Design'=>'Image');
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Caption' => 'Caption',
'Link' => 'Link'
), // Headings
'getCMSFields_forPopup' // Detail fields
// Filter clause
// Sort clause
// Join clause
);
$f->addFieldToTab('Root.Content.Main', new TextField($name='YoutubeURL',$title="YouTube Video ID: /watch?v=XXXXX&"), 'Content');
$f->addFieldToTab("Root.Content.BeforeAndDesign", new ImageField('Before'));
$f->addFieldToTab("Root.Content.BeforeAndDesign", new ImageField('Design'));
$f->addFieldToTab("Root.Content.Gallery",$manager);
return $f;
}
}
class ProjectPage_Controller extends Page_Controller {
}
ProjectHolder.php
<?php
/**
* Defines the ProjectHolder page type
*/
class ProjectHolder extends Page {
static $db = array(
);
static $has_one = array(
);
static $allowed_children = array('ProjectPage');
}
class ProjectHolder_Controller extends Page_Controller {
}
?>
ImageResource.php
<?php
class ImageResource extends DataObject
{
static $db = array (
'Caption' => 'Text',
'Link' => 'Text'
);
static $has_one = array (
'Attachment' => 'Image',
'GalleryPage' => 'GalleryPage'
/* This is where i think i should put something, gallerypage is my slideshow-- i need project page */
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Caption'),
new TextField('Link'),
new FileIFrameField('Attachment')
);
}
}
I am assuming it has something to do with the has one has many so it can link the attachments to just one gallery, I just don't know it.
Help Please :)