ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
govicinity
Forum Members
Forum Members
Posts: 125
Joined: Tue Nov 22, 2011 2:22 pm

ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Post 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".
Going up, woop, woop.
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1786
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Post by DIGI3 »

Could you not use the Group field instead? (one textarea and one text input for the class name)
Not getting the answer you need? CMSMS support options
govicinity
Forum Members
Forum Members
Posts: 125
Joined: Tue Nov 22, 2011 2:22 pm

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Post 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.
Going up, woop, woop.
govicinity
Forum Members
Forum Members
Posts: 125
Joined: Tue Nov 22, 2011 2:22 pm

Re: ECB2 Repeatable Blocks Assigning Different CSS Styles To TextArea

Post 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}
Going up, woop, woop.
Post Reply

Return to “Modules/Add-Ons”