2017 © Pedro Peláez
 

silverstripe-vendormodule simple-gallery

A simple photogallery management module

image

zirak/simple-gallery

A simple photogallery management module

  • Friday, March 16, 2018
  • by g4b0
  • Repository
  • 1 Watchers
  • 1 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 10 Versions
  • 2 % Grown

The README.md

Simple Gallery

A simple photogallery management module., (*1)

Introduction

With this module you will be able to extend each DataObjects, including Pages, in order associate to it a photogallery. If a Page needs more than a single photogallery, than it's possible to create a Gallery Dataobject, extend it with SimpleGallery, than assign it in a has_many relationship to the page. See example below., (*2)

Requirements

  • SilverStripe ^4.0 (version master/4+)
  • SilverStripe ^3.1 (version 1.+ / 3.+)
  • colymba/gridfield-bulk-editing-tools ^3.0.* (version master/4+)
  • colymba/gridfield-bulk-editing-tools ^2.1.* (version 1.+ / 3.+)
  • undefinedoffset/sortablegridfield ^2.0.* (version master/4+)
  • undefinedoffset/sortablegridfield ^0.* (version 1.+ / 3.+)

Installation

Install the module through composer:, (*3)

composer require g4b0/simple-gallery
composer update

To have a single gallery per page extend the desired page type through the following yaml:, (*4)

Page:
  extensions:
    - g4b0\SimpleGallery\SimpleGalleryExtension

Template

A really basic template is given, to use it just put this code into your Page template:, (*5)

<% include simplegallery %>

For a nice visualization into the default SS template add this CSS code:, (*6)

.simplegallery img {width: 30%; float: left; margin: 10px;}

You have to write your own .ss files for more advanced features. Just overwrite template/simplegallery.ss into your theme and loop over $SortedImages writing your HTML code:, (*7)

<div class="simplegallery">
<% loop SortedImages %>
    <% if $CustomLink %>
     <a href="$CustomLink">$Image</a>
    <% else %>
     $Image
    <% end_if %>
<% end_loop %>
</div>

You can access the following image variable:, (*8)

$CustomLink $Title $Text $Disabled $SortOrder, (*9)

If you prefer to have multiple sortable gallery in a specific page type simply add an has_many relationship like the following example:, (*10)

class Portfolio extends Page {

    private static $has_many = array(
            'Galleries' => 'SimpleGallery'
    );

    public function getCMSFields() {
        $fields = parent::getCMSFields();

        $gridFieldConfig = GridFieldConfig_RelationEditor::create();
        $gridFieldConfig->addComponent(new GridFieldSortableRows('SortOrder'));
        $field = new GridField(
                        'Galleries', 'Galleries', $this->SortedGalleries(), $gridFieldConfig
        );
        $fields->addFieldToTab('Root.Galleries', $field);

        return $fields;
    }

    public function SortedGalleries() {
        return $this->Galleries()->sort('SortOrder');
    }

}

Template

Just like simplegallery, a very basic template is given, to use it just put this code into your Page template:, (*11)

<% include simplegalleries %>

For a nice visualization into the default SS template add this CSS code:, (*12)

.simplegallery {clear: both;}
.simplegallery img {width: 30%; float: left; margin: 10px;}

You have to write your own .ss files for more advanced features. Just overwrite template/simplegalleries.ss into your theme and loop over $SortedGalleries, and then over $SortedImages, (*13)

<% loop $SortedGalleries %>
    <div class="simplegallery">
        <article>
            <h3>$Name</h3>
            $Description
            <div>
            <% loop SortedImages %>
                <% if $CustomLink %>
                 <a href="$CustomLink">$Image</a>
                <% else %>
                 $Image
                <% end_if %>
            <% end_loop %>
            </div>
        </article>
    </div>
<% end_loop %>

Config

Editing _config/simplegallery.yml it's possible to modify gallery behaviour:, (*14)

* gallery_name: The gallery name that appear in backend tabs (default: Gallery)

* folder_path: path where the uploaded images are stored (default: simplegallery), (*15)

The Versions

16/03 2018

dev-master

9999999-dev

A simple photogallery management module

  Sources   Download

GPL-2 GPL-2.0-only

The Requires

 

by Gabriele Brosulo
by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

16/03 2018

4.0.0

4.0.0.0

A simple photogallery management module

  Sources   Download

GPL-2.0-only

The Requires

 

by Gabriele Brosulo

gallery image photo silverstripe photogallery

22/12 2017

3.0.x-dev

3.0.9999999.9999999-dev

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

22/12 2017

3.0

3.0.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

31/03 2016

1.4

1.4.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

30/09 2015

1.3.1

1.3.1.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

23/01 2015

1.3

1.3.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

18/11 2014

1.2

1.2.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image photo silverstripe photogallery

08/07 2014

1.1

1.1.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery image silverstripe photogallery

04/07 2014

1.0

1.0.0.0

A simple photogallery management module

  Sources   Download

GPL-2

The Requires

 

by Gabriele Brosulo - Zirak

gallery silverstripe photogallery