Page 1 of 1

ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Posted: Tue Apr 29, 2025 11:37 am
by govicinity
CMSMS 2.2.21
AceEditor2 1.05
Captcha 1.0
CMSMSExt1.0.1
ECB2 2.4
Gallery 2.4.2
SitemapMgr 1.6
SmartImage 1.0
SmartyExt 1.0

I am looking to have several repeatable textarea blocks on the same page, what I'd really love to do is to be able to assign a different background colour to the containing div of that textarea repeatable block. I have had a really good look through the forums and have also asked ChatGPT (which was useless of course).

My current code:

Code: Select all

{content_module module="ECB2" field="textarea" label='Textarea' block="Repeatable_Content" repeater="1" wysiwyg="1" assign="Repeatable_Content" description="This is an editable area you can create multiple fields of to allow you to have text and images in the same box"}
        {foreach from=$Repeatable_Content item=row}
          <div class="repeatable-block">
            {$row}
          </div>
        {/foreach}        
The output I'd like to achieve...

Code: Select all

<div class="repeatable-block {insert choosable css style here}">
<p><img style="float: left;" src="uploads/PageImages/image-here.jpg" alt="image-here" width="188" height="289" />Here is some exciting text.</p>
<p>Here is some exciting text.</p>
<p>Here is some exciting text.</p>
<hr /></div>
As you can see I'd like to be able to add a choosable style after the initial "repeatable-block" style, this will enable me to have alternating colours for the repeatable-block div going down the webpage for interest.

I can't see any way currently of being able to add a choosable style extra to the field="textarea".

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Posted: Wed Apr 30, 2025 1:53 am
by DIGI3
Could you not use the Group field instead? (one textarea and one text input for the class name)

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Posted: Thu May 01, 2025 9:07 am
by govicinity
I think that's exactly what I'm after, I saw that, but didn't realise that's what I could do with it, you've sparked something in my head now, I'll go and give it a go and code something up and post it here once I've got it working for people wanting to do the same thins as me and mark it as solved once I have it working.

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Posted: Thu May 01, 2025 4:47 pm
by govicinity
OK, here's my code that is now working wonderfully, thanks for the pointer DIGI3

Code: Select all

        {content_module module="ECB2" field="group" block="RepeatableContent" assign="RepeatableContent" description="This is an editable area you can create multiple fields of to allow you to have text and images in the same box"
        sub1_field="textarea" sub1_name="Textarea" sub1_label='Textarea' sub1_wysiwyg="1"
        sub2_field="select" sub2_name="Style" sub2_label="Style" sub2_values='Light Blue Tint=lightbluetint, Dark Blue Tint=darkbluetint'
        }
        
        {if !empty($RepeatableContent->sub_fields)}
            {foreach $RepeatableContent->sub_fields as $sub_field}
                  <div class="repeatable-block {$sub_field->Style}">
                    {$sub_field->Textarea}
                  </div>
            {/foreach}
        {/if}