Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS3: gallery and slider


Go to End


3 Posts   1251 Views

Avatar
aurum

Community Member, 5 Posts

27 July 2012 at 9:50pm

Edited: 27/07/2012 10:03pm

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!

Avatar
Craftnet

Community Member, 58 Posts

27 July 2012 at 10:53pm

Edited: 27/07/2012 10:55pm

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

Avatar
aurum

Community Member, 5 Posts

28 July 2012 at 2:22am

Thank you, Craftnet!
Unfortunately, I'm not a PHP programmer, but I'll try your method.