How do you have your headings set up in your DOM instance?
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
ParentID not needed... Maybe?
- Previous 10 entries
- 1
- Page 22(current)
I got it working! Here's what I have...
HOMEPAGE
class HomePage extends SiteTree
{
public static $db = array();
public static $has_one = array();
public static $has_many = array(
'Rotator' => 'RotatorImg'
);
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Rotator", new DataObjectManager(
$this,
'Rotator',
'RotatorImg',
array(
'RotAlt' => 'Image Alt Text',
'RotTitle' => 'Link Title',
'ReturnRotEnabledYesNo' => 'Enabled',
'ReturnRotWindowYesNo' => 'New Window',
'Thumbnail' => 'Preview'
),
'getCMSFields_forPopup'
));
return $fields;
}
....
function GetRotator()
{
return DataObject::get('RotatorImg', "RotEnabled = 1", "SortOrder", "", "", "DataObjectSet");
}
...
}
OBJECT
class RotatorImg extends DataObject
{
static $db = array(
'RotLink' => 'Text',
'RotAlt' => 'Text',
'RotTitle' => 'Text',
'RotWindow' => 'Boolean',
'RotEnabled' => 'Boolean'
);
static $has_one = array(
'HomePage' => 'HomePage',
'RotImage' => 'Image'
);
function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('RotAlt', "Rotator Image Alt Text"),
new TextField('RotTitle', "Rotator Link Title"),
new TextField('RotLink', "Rotator Link"),
new CheckboxField('RotWindow', 'Open in new window?'),
new CheckboxField('RotEnabled', 'Display on Website?'),
new ImageField('RotImage', "Rotator Image")
);
}
function Thumbnail()
{
if ($this->RotImage())
return $this->RotImage()->CroppedImage(100,100);
else
return null;
}
function ReturnRotEnabledYesNo()
{
if ($this->RotEnabled)
return "Yes";
else
return "No";
}
function ReturnRotWindowYesNo()
{
if ($this->RotWindow)
return "Yes";
else
return "No";
}
}
Anything you see that I should be doing different. I have only been working with Silverstripe for about a week. So bare with me :)
- Previous 10 entries
- 1
- Page 22(current)