首页 > 解决方案 > 将速度转换为 freemarker 但不工作

问题描述

我已经为网络内容创建了一个结构和模板,以通过 Asset Publisher 发布文章。

结构源和视图如下所示:

{
    "availableLanguageIds": [
        "en_US"
    ],
    "defaultLanguageId": "en_US",
    "fields": [
        {
            "label": {
                "en_US": " File Title "
            },
            "predefinedValue": {
                "en_US": "  "
            },
            "style": {
                "en_US": ""
            },
            "tip": {
                "en_US": "  "
            },
            "dataType": "string",
            "indexType": "keyword",
            "localizable": true,
            "name": "File_Title",
            "readOnly": false,
            "repeatable": true,
            "required": true,
            "showLabel": true,
            "type": "text",
            "nestedFields": [
                {
                    "label": {
                        "en_US": " Select File "
                    },
                    "predefinedValue": {
                        "en_US": "  "
                    },
                    "style": {
                        "en_US": ""
                    },
                    "tip": {
                        "en_US": " Browse the file from  NEWS folder present under Disney "
                    },
                    "dataType": "document-library",
                    "fieldNamespace": "ddm",
                    "indexType": "keyword",
                    "localizable": true,
                    "name": "Select_File",
                    "readOnly": false,
                    "repeatable": false,
                    "required": true,
                    "showLabel": true,
                    "type": "ddm-documentlibrary"
                }
            ]
        }
    ]
}

看法:

在此处输入图像描述

现在标记到上述结构的模板源在 Liferay 6.2 中的速度语言中运行良好,如下所示:

#if (!$File_Title.getSiblings().isEmpty())
    #foreach ($cur_File_Title in $File_Title.getSiblings())
        <h3>
         <a href="$cur_File_Title.Select_File.getData()" target="_blank">$cur_File_Title.getData()</a>
        </h3>
        #end
#end

有一次,我将我的应用程序迁移到 DXP 7.2 并在我的应用程序中使用相同的结构和模板(选择相同的 .vm 模板语言),资产发布者中的结构视图不允许我在文本框中输入任何值。

在此处输入图像描述

因此,我尝试将 Velocity 代码迁移到 freemarker 语言,如下所示。

<#if File_Title.siblings?size !=0>
    <#list File_Title.siblings as cur_File_Title>
        <h3>
            <a href="${cur_File_Title.Select_File.data}" target="_blank">${cur_File_Title.data}</a>
        </h3>
    </#list>
</#if>

现在结构视图允许我输入值,但是当我尝试单击已发布的文章时,附件未显示。 在此处输入图像描述

下面是屏幕,它目前在 6.2 中的显示方式,锚链接有一个文档媒体 URL 来下载附件。 在此处输入图像描述

标签: jspliferayfreemarkervelocity

解决方案


推荐阅读