Is there a gallery module or any module for making a slider? I really need a slider and a gallery to my site. Help, please!
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.
Hi,
Build yourself slider and a gallery - you can better customize it for your requirements.
I usually use the slider: bxSlider,
To the gallery: fancybox,
For example to gallery use:
<?php
class Gallery extends DataObject
{
static $db = array (
);
static $has_one = array (
'Photo' => 'Image',
'HomePage' => 'HomePage' //Page where the gallery will be available
);
function getCMSFields() {
return new FieldSet(
new UploadField('Photo')
);
}
}
And in Page from has_many (in my example HomePage)
<?php
class HomePage extends Page {
(...)
static $many_many = array(
'Gallerys' => 'Image'
);
public function getCMSFields() {
$fields = parent::getCMSFields();
(...)
$fields->addFieldToTab('Root.Gallery', new UploadField('Gallerys', 'Gallery'));
return $fields;
}
}
class HomePage_Controller extends Page_Controller {
public function init() {
parent::init();
Requirements::javascript('https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js');
Requirements::javascript("mysite/javascript/jquery.bxSlider.min.js");
Requirements::javascript("mysite/javascript/option.bxSlider.js"); //option for bxslider
}
}
in template use
<% loop Gallerys %>
<a rel="gallery" href="$URL">$SetWidth(80)</a>
<% end_loop %>
Sorry for my bad English
Thank you, Craftnet!
Unfortunately, I'm not a PHP programmer, but I'll try your method.