WYSIWYG field > multiple divs > carousel

3 posts by 2 authors in: Forums > CMS Builder
Last Post: June 17, 2015   (RSS)

By Toledoh - June 16, 2015

Hi All.

I have a field which can end up being a large amount of text.  To keep the style of the site, I want to break this long text into chucks and wrap each chunk in a div, then display those divs in a carousel.

So, I'm thinking that somehow I could convert a single field into an array - maybe based on X number of characters of text?  Then create a for-each loop for each div? From there I can handle the display...

Can anyone help with this?

Cheers,

Tim (toledoh.com.au)

By Toledoh - June 17, 2015

Thanks Dave - looking good.  

<?php
$textWithTabs = wordwrap($record['carousel_text'], 150, "\t");
$textChunkArray = explode("\t", $textWithTabs);
?>

<div class="swiper-carousel2">
<div class="swiper-wrapper">
<?php foreach ($textChunkArray as $textblock): ?>
<div class="swiper-slide">
<?php echo ($textblock) ?>
</div>
<?php endforeach ?>
</div>
</div>

Cheers,

Tim (toledoh.com.au)