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).
A slide can contain:
- Title
- Text (no html)
- Image + width/height hint
- A link
Once slides are added to the element, they can be sorted via drag/drop under the 'Slides' tab.
Configuration for the slide:
default_thumb_width
the default width of a thumbnail imagedefault_thumb_height
the default height of a thumbnail imageallowed_file_types
allowed upload types for images
The module is unopinionated about requirements. To provide your own requirements/slider implementation:
<?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');
}
}
Add project configuration, in the standard Silverstripe way.
NSWDPC\Elemental\Models\Slider\ElementSlider:
extensions:
- 'My\Project\Extensions\ElementSliderExtension'
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.