8

I have created a content template where user can create multiple cards/boxes.It works well but i would like to change the css if user create just one box. I tried it with getList()?size but it didnt work. Any idea how can I proof if the size is 1?

<div id="my-cards">
    <#list boxen.getSiblings() as box>
     <#assign i = box.getList()?size>   
       <#if i==1>
       <p>There is one box</p>
       </#if>
        <!-- Card-->
        <div class="card-box mb-3">
            <!-- Image-->
            <div class="card-pic">
                    <#if box.image.getData() != "">
                    <img src="${box.image.getData()}" />
                </#if>
            </div>
            <!--  Content-->
            <div class="card-box-content">


                <#if box.headline.getData() != "">
                <h2 class="title">${box.headline.getData()}</h2>
                 </#if>

                 <#if box.content.getData() != "">            
                <p class="description">${box.content.getData()}</p>
                </#if>
                <div class="card-box-footer">
                    <br />

            </div>
        </div>

    </#list>   
</div>
user1953051
  • 321
  • 2
  • 7
  • 21

1 Answers1

11

To get the size of your list you must use list?size, that means boxen.getSiblings()?size for this example. I don't think box.getList() is valid.

Check this example:

   <#assign listA = ['one']>
   <#assign listB = ['one' , 'two']>
   <#list listA as element>
   <#if (listA?size = 1)>
     ${element}
   </#if>
   </#list>
   <#list listB as element>
   <#if (listB?size = 1)>
     ${element}
   </#if>
   </#list>

only the first condition is fulfilled and the output is: one

Fotiou D.
  • 431
  • 6
  • 11