Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add asset publisher configuration options in LifeRay 6.2

When using an asset publisher, you can change Display Settings in the asset publisher configuration panel. If you select the Abstracts display template, a new option will be available for you (Abstract Length). How can I add an option like that to my Application Display Templates (ADT) ?

Example for the Abstracts template :

enter image description here

Example for my custom template (Abstract Length not available):

enter image description here

like image 707
Jonathan Hell Avatar asked Aug 01 '14 15:08

Jonathan Hell


People also ask

How do I set up an asset publisher in Liferay?

After you've added a scope, a new Select button appears under the Asset Entries heading. A list of assets selected for display appears in the Asset Entries section. You can select assets to be displayed by clicking on the appropriate Select button. One button appears for each configured scope.

What is asset publisher in Liferay?

The Asset Publisher is a highly configurable application that lets you query for mixed types of content on the fly. By giving you the ability to control what and how content is displayed from one location, the Asset Publisher helps you to “bubble up” the most relevant content to your users.

How do I customize my Liferay page?

Click the Customizable selector button to activate customizations. Figure 1: To enable page customizations, click on the *Configure Page* button next to the page, expand the *Customization Settings* area, and click on the *Customizable* button. Select the sections of the page that should be customizable.

What is asset entry in Liferay?

An asset entry row's classPK represents the primary key of the entity represented by the asset. E.g., the classPK field of an asset entry row corresponding to a web content article contains the primary key of the web content article in the JournalArticle table of Liferay's database.


1 Answers

You can use substring in velocity code written inside ADT built for news asset publisher, check below code to display 100 character only of about us page

#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='country-portal-image']") )
        #set( $countryPortalImage = $xPathSelector.selectSingleNode($rootElement).getStringValue() )

        #set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='country-portal-title']") )
        #set( $countryPortalTitle = $xPathSelector.selectSingleNode($rootElement).getStringValue() )

        #set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='country-flag-icon']") )
        #set( $countryFlagIcon = $xPathSelector.selectSingleNode($rootElement).getStringValue() )

        #set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='country-portal-about-us']") )
        #set( $countryPortalAboutUs = $xPathSelector.selectSingleNode($rootElement).getStringValue().substring(0,100) )


        #set( $link = $renderer.getURLViewInContext($renderRequest, $renderResponse, '') )
        #set( $viewURL = $assetPublisherHelper.getAssetViewURL($renderRequest, $renderResponse, $entry))

        #set($news-summary =$entry.getSummary($locale))
         #set($date = $dateTool.format("dd/MM/yyyy hh:mm:ss", $dateTool.toDate( "EEE, dd MMM yyyy hh:mm:ss Z" , $entry.getPublishDate())))
        <div class="new">
            <h1 class="title">$entry.getTitle($locale)</h1>
            $date
                 <img src="$countryFlagIcon"/> 
                <img src="$countryPortalImage"/> 
                <h3 class="sub-title">$countryPortalAboutUs</h3>
            <p class="read-more">
                <a href="$viewURL">Read More</a>
            </p>
        </div>
    #end
#end
</div>
#end
like image 160
Nesrin Avatar answered Oct 02 '22 04:10

Nesrin