diff --git a/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx b/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx index d3fbc1d6b..23a072694 100644 --- a/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx +++ b/src/components/ItaliaTheme/Blocks/Listing/SliderTemplate.jsx @@ -16,6 +16,7 @@ import PropTypes from 'prop-types'; import { UniversalLink } from '@plone/volto/components'; import cx from 'classnames'; import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; +import {shuffle} from 'lodash'; const messages = defineMessages({ viewImage: { @@ -206,6 +207,7 @@ const SliderTemplate = ({ show_dots = true, autoplay = false, autoplay_speed = 2, //seconds + shuffle_items = false, reactSlick, }) => { const intl = useIntl(); @@ -345,7 +347,7 @@ const SliderTemplate = ({ )} - {items.map((item, index) => { + {(shuffle_items ? shuffle(items) : items).map((item, index) => { const image = ListingImage({ item, loading: index === 0 ? 'eager' : 'lazy', diff --git a/src/config/Blocks/ListingOptions/sliderTemplate.js b/src/config/Blocks/ListingOptions/sliderTemplate.js index 7c82dc562..982ab0119 100644 --- a/src/config/Blocks/ListingOptions/sliderTemplate.js +++ b/src/config/Blocks/ListingOptions/sliderTemplate.js @@ -31,6 +31,11 @@ const messages = defineMessages({ id: 'autoplay_speed_description', defaultMessage: 'La velocità di autoplay deve essere espressa in secondi.', }, + shuffle_items: { + id: 'shuffle_items', + defaultMessage: + 'Ordine casuale (in caso di paginazione solo la prima pagina sarà ordinata casualmente)', + }, }); export const addSliderTemplateOptions = ( @@ -99,5 +104,16 @@ export const addSliderTemplateOptions = ( { type: 'number', default: 1 }, pos, ); + pos++; + + addSchemaField( + schema, + 'shuffle_items', + intl.formatMessage(messages.shuffle_items), + null, + { type: 'boolean', default: false }, + pos, + ); + return pos; };