WYSIWYG field > multiple divs > carousel

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

By Dave - June 17, 2015

Can you have the source text be a textbox?  It's much easier with text:

$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam id
vestibulum leo. Proin non condimentum libero. Vestibulum iaculis consectetur
purus lobortis tristique. Sed malesuada aliquet nibh. Aliquam erat volutpat.
Aliquam erat volutpat. Integer convallis sapien sed sem lacinia, at malesuada
metus consectetur. Vestibulum eget varius diam. Cras aliquet nec nibh quis
lacinia. Aenean tempus auctor lacinia. Fusce placerat, sapien quis condimentum
varius, nunc nulla pharetra lorem, non tristique tortor lectus vel risus. Aenean
malesuada sem id nulla sodales sagittis.";

$textWithTabs = wordwrap($text, 150, "\t");
$textChunkArray = explode("\t", $textWithTabs);
showme($textChunkArray);
exit;

Outputs: 

Array
(
    [0] => Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam id 
vestibulum leo. Proin non condimentum libero. Vestibulum iaculis consectetur 
purus
    [1] => lobortis tristique. Sed malesuada aliquet nibh. Aliquam erat volutpat. 
Aliquam erat volutpat. Integer convallis sapien sed sem lacinia, at malesuada
    [2] => 
metus consectetur. Vestibulum eget varius diam. Cras aliquet nec nibh quis 
lacinia. Aenean tempus auctor lacinia. Fusce placerat, sapien quis
    [3] => condimentum 
varius, nunc nulla pharetra lorem, non tristique tortor lectus vel risus. Aenean 
malesuada sem id nulla sodales sagittis.
)

With HTML you need to match the tags and make sure you close them, and don't split in the middle of a tag, etc.  Possible, but fair bit trickier.

Let me know if the above works for you.

Dave Edis - Senior Developer
interactivetools.com

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)