Skip to content

Latest commit

 

History

History
79 lines (52 loc) · 1.87 KB

001_index.md

File metadata and controls

79 lines (52 loc) · 1.87 KB

Documentation

Element

The element contains a title, HTML content and a link for the entire element.

In your template, the HomepageHero field can be used to define a different type of slider (example: a 'hero' slider on the home page).

Slide

A slide can contain:

  1. Title
  2. Text (no html)
  3. Image + width/height hint
  4. A link

Once slides are added to the element, they can be sorted via drag/drop under the 'Slides' tab.

Configuration for the slide:

  1. default_thumb_width the default width of a thumbnail image
  2. default_thumb_height the default height of a thumbnail image
  3. allowed_file_types allowed upload types for images

Adding requirements

The module is unopinionated about requirements. To provide your own requirements/slider implementation:

Add an extension

<?php

namespace My\Project\Extensions;

use SilverStripe\View\Requirements;
use SilverStripe\Core\Extension;

/**
 * Provide requirements for a slider
 */
class ElementSliderExtension extends Extension
{

    /**
     * Add requirements
     */
    public function sliderRequirements()
    {

        Requirements::javascript('https://example.com/some/js/requirement.js');

    }

}

Apply the configuration

Add project configuration, in the standard Silverstripe way.

NSWDPC\Elemental\Models\Slider\ElementSlider:
  extensions:
    - 'My\Project\Extensions\ElementSliderExtension'

Modify HTML templates

Override the following templates in your project or project theme to use your own HTML.

templates/Includes/SlideImage.ss -> a slide image
templates/NSWDPC/Elemental/Models/ElementSlider.ss -> the slider HTML for the element
templates/NSWDPC/Elemental/Models/Slide.ss -> the slide HTML

A <figure> tag is a good choice represent the slide. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure for examples with and without images.