Not sure if the title is overly confusing or makes no sense at all so let me explain.
I have to build donation pages that each have a set of 6 donation buttons. Each donation button has two options. "one time donation" and "recurring" donation. I then need to have this occur accross different supported projects. Each donation button is uniquely identified by its code because I have to be able to identify what people are donating to. Setting up the buttons is not a problem, i have all of the code ready for this.
I was trying to set up a DOM that allows me to create each object and in the popup include: donation value, donation category, 2 sets of donation code for the buttons and image to display on the front end
I accomplished this using DOM no problem. BUT, if I create a page in the CMS, using the donatePage type and title it Project 1, i can add each donation value and subsequent field.
When I go to create Project 2, using the same DOM pagetype, the items from the previous Project are there as well.
What I am trying to avoid is every time I have to create a new project I have to then set up a new DOM pagetype (i.e. pageType2.php)
I assume there is a much easier way to do this that I am just not familiar with. If anyone can make a suggestion I would greatly appreciate it.
For ease, I am pasting the code I was working off of from ssbits.com http://www.ssbits.com/tutorials/2010/dataobjects-as-pages-part-1-keeping-it-simple/
See below and thanks for your help!!
StaffMember.php
<?php
class StaffMember extends DataObject
{
//db fields
static $db = array (
'Name' => 'Varchar(255)',
'Role' => 'Varchar(100)',
'Description' => 'Text'
);
//Relations
static $has_one = array (
'StaffPage' => 'StaffPage',
'Photo' => 'Image'
);
//Fields to show in the DOM table
static $summary_fields = array(
'Thumb' => 'Photo',
'Name' => 'Name',
'Role' => 'Role'
);
//Fields for the DOM Popup
public function getCMSFields()
{
return new FieldSet(
new TextField('Name'),
new TextField('Role'),
new TextareaField('Description', 'Description'),
new ImageField('Photo', 'Photo', Null, Null, Null, 'Uploads/staff-photos/')
);
}
//Generate our thumbnail for the DOM
public function getThumb()
{
if($this->PhotoID)
return $this->Photo()->CMSThumbnail();
else
return '(No Image)';
}
}
StaffPage.php
<?php
class StaffPage extends Page {
static $has_many = array(
'StaffMembers' => 'StaffMember'
);
public function getCMSFields()
{
$fields = parent::getCMSFields();
$manager = new DataObjectManager(
$this,
'StaffMembers',
'StaffMember'
);
$fields->addFieldToTab("Root.Content.StaffMembers", $manager);
return $fields;
}
}
class StaffPage_Controller extends Page_Controller {
}