In WEBFLOW We copy content from a CMS into a Slider
It is copied automatically, we create 20 slides or more if necessary, once the content is copied the remaining unused slides will be deleted.
This way differs with Div which has to have custom attribute too-slider-container=<complex_name> which wraps the CMS and Slider so that on the same page there can be several sliders.
- Create CMS component
- Add internal component linking to CMS entries
- in the
container-gridwe add custom attributetoo-slider-source=container - in the
collection itemwe add custom attributetoo-slider-source=item
- Creamos Slider
- Add first item Slide and assign custom attribute
too-slider-target=itemcopy with hot keysCTRL+Cand paste about 20 times withCTRL+V. - In the previous level Mask we assign custom attribute
too-slider-target=container
- Add first item Slide and assign custom attribute
- Wrap the two components with a
Div, in side panelSettingsscroll down and addcustom attributetoo-slider-container=<complex_name>. - in the page configuration we add code
Before tag:
<script>
(function () {
$("[too-slider-container]").each(function () {
var $container = $(this);
var $sourceContainer = $container.find('[too-slider-source="container"]');
var $sourceItems = $sourceContainer.find('[too-slider-source="item"]');
var $targetContainer = $container.find('[too-slider-target="container"]');
var $targetItems = $targetContainer.find('[too-slider-target="item"]');
$sourceItems.each(function(index) {
var sourceContent = $(this).html();
if (index < $targetItems.length) {
$($targetItems[index]).html(sourceContent);
}
});
if ($targetItems.length > $sourceItems.length) {
for (var i = $sourceItems.length; i < $targetItems.length; i++) {
$($targetItems[i]).remove();
}
}
});
})();
</script>- with keys 1 to 4 we change the views from
DesktoptoMobil, select 1 and hide sliderDisplay: None, select 4 and hide CMS and activate Slider.
Done!
Visual Structure in html:
<div too-slider-container="container1">
<div too-slider-source="container">
<div too-slider-source="item">Item A</div>
<div too-slider-source="item">Item B</div>
</div>
<div too-slider-target="container">
<div too-slider-target="item">1</div>
<div too-slider-target="item">2</div>
<div too-slider-target="item">3</div> <!-- it will be eliminated -->
</div>
</div>