husseinemam
8/11/2017 - 10:33 PM

Liferay 6.2 Application Display Template (ADT) to display nested repeatable elements (images)

Liferay 6.2 Application Display Template (ADT) to display nested repeatable elements (images)

#if (!$entries.isEmpty())
    <div class="news">
    #foreach ($entry in $entries)
        #set($renderer = $entry.getAssetRenderer() )
        #set($className = $renderer.getClassName() )
        #if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
            #set( $journalArticle = $renderer.getArticle() )
            #set( $document = $saxReaderUtil.read($journalArticle.getContent()) )
            #set( $rootElement = $document.getRootElement() )
            #set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='Image_Text']/dynamic-element[@name='Image10593']") )
            #set( $Images = $xPathSelector.selectNodes($rootElement) )
            #set( $link = $assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $entry) )

            
            <div class="new">
                <h1 class="title">$entry.getTitle($locale)</h1>
                #foreach($img in $Images)
                    <p>$img.getStringValue()</p>
                    <img src="$img.getStringValue()" />
                #end
                <p class="read-more">
                    <a href="$link">Read More</a>
                </p>
            </div>
        #end
    #end
    </div>
#end