Search code examples
liferayliferay-6velocityfreemarker

Liferay freemarker list tag - Velocity counterpart


Within my Liferay 6.2 EE Webcontent template i have the following freemarker code:

<#list teaserHeader.getSiblings() as teaser_header>
    <#if getterUtil.getBoolean(teaser_header.teaserVisible.getData())>
        <h2 class="section-headline">${teaserHeader.getData()?html}</h2>
            <div class="inner-15">
                <div class="general-wrapper inner-15-content bound" >
                    <#if teaser_header.teaserImage.getData() != "">
                    <div class="product-image-wrapper left">
                        <img src="${teaser_header.teaserImage.getData()}" width="" height=""/>
                    </div>
                    </#if>
                    <div class="product-teaser-info left">${teaser_header.teaserContent.getData()}</div>
                    <div class="clearfix"></div>
                </div>
            </div>
    </#if>
</#list>

Unfortunately we have to switch to Velocity.

What's the best approach to transform freemarkers list tag to Velocity ?

I already adopted everything else (if tags, method calls, ...)

But i have some troubles with the list tag.

I tried to do it with foreach in Velocity but i failed...

Thanks


Solution

  • In velocity it should look something like this:

    #if (!$teaserHeader.getSiblings().isEmpty())
        #foreach ($teaser_header in $teaserHeader.getSiblings())
            ...
        #end
    #end