I have a problem similar described on the silverstripe problem: [http://www.silverstripe.org/dataobjectmanager-module-forum/show/19853][1]
I have a working DataObject, wich mainly provides a Title, Caption and Image. This goes in an has_many, which should provide a slider in the template output.
The CMS part is all done, meaning I can add multiple 'slides' from a tab in the SiteConfig. Only the output in the template won't seem te happen.
For the codes I use:
SingleSlide extends DataObject:
public function getCMSFields_forPopup()
{
return new FieldSet(
new ImageUploadField('SlideImg', 'Afbeelding van slide'),
new TextField('SlideTitle'),
new TextField('SlideCaption'),
new SimpleSiteTree('SlideLinkID')
);
}
In SiteConfigOverride
$fields->addFieldToTab('Root.SliderA', new ComplexTableField(
$this->owner, 'SliderA', 'SingleASlide',
array('SlideImg' => 'Afbeelding van slide', 'SlideTitle' => 'Titel van Slide', 'SlideCaption' => 'Tekst bij slide', 'SlideLink.Title' => 'Link naar pagina'
)));
All left to do is be able to get the Output from here in the template. Any help would be great!
Regards,
Kay
You can add a function to the Page_Controller class in Page.php such as below
class Page_Controller extends ContentController {
...
function SingleSlideList() {
return DataObject::get('SingleSlide');
}
...
}
Then in your ss file, you can use something like the following:
<% control SingleSlideList %>
<div class="Image"><% control SlideImg %><% control CroppedImage(880,493) %><img src="$BaseHref$Filename.XML" height="$Height" width="$Width"><% end_control %><% end_control %></div>
<div class="Content">
<h2>$SlideTitle</h2>
<p>$SlideCaption</p>
<p><a href="$SlideLinkID.Link">my link</a></p>
</div>
<% end_control %>
you will need to change the html to work with what you need.