Jump to:

23490 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » SS3: gallery and slider

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

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

Page: 1
Go to End
Author Topic: 661 Views
  • aurum
    Avatar
    Community Member
    5 Posts

    SS3: gallery and slider Link to this post

    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!

  • Craftnet
    Avatar
    Community Member
    58 Posts

    Re: SS3: gallery and slider Link to this post

    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

  • aurum
    Avatar
    Community Member
    5 Posts

    Re: SS3: gallery and slider Link to this post

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

    661 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.