How to add publisher configuration settings in LifeRay 6.2

When using an asset publisher, you can change the Display Settings in the asset publisher configuration panel. If you select the Tag Abstract template, a new option will be available to you ( Abstract Length ). How to add such a parameter to my application mapping templates (ADT)?

An abstract template example:

enter image description here

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

enter image description here

+6
source share
4 answers

You can use the substring in the speed code written inside ADT, created for the news asset publisher, check the code below to display only 100 characters about our 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 
+1
source

You can create a JSP hook to configure Publisher Asset.

The original configuration is displayed / html / portlet / asset _publisher / configuration.portal.jsp.

You can include the original jsp in your hook, and then add your own settings.

Example:

 <%-- Include the original Asset Publisher configuration JSP. --%> <%@include file="/html/portlet/asset_publisher/configuration.portal.jsp"%> <%-- Read current value from portlet preferences. --%> <% String abstractLength = portletPreferences.getValue("abstractLength", "100"); %> <%-- Hidden div with custom input fields. --%> <div id="customPreferences" style="display: none;"> <aui:fieldset label="fieldset.abstractLength"> <aui:input name="abstractLength" label="abstractLength" value="<%= abstractLength %>"> <aui:validator name="number"/> <aui:validator name="min">1</aui:validator> </aui:input> </aui:fieldset> </div> <%-- JS code to place custom preferences at the end of Display Settings tab. --%> <%-- It uses jQuery, but it not a requirement. --%> <script> $(document).ready(function () { // find div with custom preferences var $customPreferences = $("#customPreferences"); // find the last fieldset on Display Settings tab var displaySettingsLastFieldset = $(".nav-tabs:eq(1)").siblings("div:eq(1)").children().filter("fieldset").last(); // insert custom preferences after the last fieldset on Display Settings tab $customPreferences.insertAfter(displaySettingsLastFieldset); // show custom preferences $customPreferences.show(); }); </script> 

This is a good approach to extend the original JSP - i.e. turn on the original, and then perform the setting. Thus, there are good chances for a painless upgrade to future versions of Liferay.

For general guidelines for implementing JSP interceptors, see the Lideray Developer Guide .

0
source

You can get a list of all the available portletPreference values ​​available to the ADT publisher using:

 <#list portletPreferences?keys as prop > <li> ${prop} </li> </#list> 

So, for your example, you can get the abstract length value set by the user using:

 abstractLength: ${portletPreferences.abstractLength[0]} 
0
source

the best way is if you create your own ADT and then control the length of the content in the ADT instead of unnecessarily connecting the jsp AP.

-1
source

Source: https://habr.com/ru/post/973233/


All Articles