如何在LifeRay 6.2中添加资产发布者配置选项

Jon*_*ell 6 liferay liferay-6

使用资产发布者时,您可以在资产发布者配置面板中更改" 显示设置".如果选择摘要显示模板,则可以使用新选项(抽象长度).如何在我的应用程序显示模板(ADT)中添加这样的选项?

摘要模板的示例:

在此输入图像描述

我的自定义模板示例(抽象长度不可用):

在此输入图像描述

Tom*_*nos 0

您可以创建 JSP 挂钩来自定义 Asset Publisher 配置。

原始配置由/html/portlet/asset_publisher/configuration.portal.jsp 呈现。

在您的挂钩中,您可以包含原始 jsp,然后添加您自己的首选项。

例子:

<%-- 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's 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>
Run Code Online (Sandbox Code Playgroud)

这是扩展原始 JSP 的好方法 - 即。包括原来的,然后进行定制。这样,就有很大机会轻松更新 Liferay 的下一个版本。

有关如何实现 JSP 挂钩的一般准则,请参阅Liferay 开发人员指南