liferayfreemarkerliferay-7

How I get the field smallAttributeValue from table ddmfieldattribute in Liferay 7.4?


Liferay 7.4 stores the structure data in the "ddmfieldattribute" table. I'm trying to get the fields of the structures in the ADT template, but I can't find the solution.

The structure has the following fields:

The ADT code is as follows:

<#assign dlService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")>

<#if entries?has_content>
    <#list entries as entry>
        <#if entry.getClassName() == "com.liferay.journal.model.JournalArticle" >      
            //Get the fields from the structure
        </#if>
    </#list>
</#if>

Regards!


Solution

  • The code is working fine. I have managed to get the data from the "title" and "content" fields of the structure in an ADT template. (Liferay 7.4)

    <#assign dlService = serviceLocator.findService("com.liferay.document.library.kernel.service.DLFileEntryLocalService")>
    <#assign ddmFieldLocalService = serviceLocator.findService("com.liferay.dynamic.data.mapping.service.DDMFieldLocalService")/>
    
    <#if entries?has_content>
        <#list entries as entry>
            <#if entry.getClassName() == "com.liferay.journal.model.JournalArticle" >      
                <#assign assetRenderer = entry.getAssetRenderer()/>
                <#assign journalArticle = assetRenderer.getAssetObject() />
                <#assign ddmStructure = journalArticle.getDDMStructure() />
                <#assign ddmForm = ddmStructure.getDDMForm()/>
                <#assign ddmFormValues = ddmFieldLocalService.getDDMFormValues(ddmForm, journalArticle.getId()) />
                <#assign ddmFormFieldValues = ddmFormValues.getDDMFormFieldValues() />
    
                <#list ddmFormFieldValues as fieldName>
                    <#if fieldName.getFieldReference() == 'titulo'>
                        ${fieldName.getValue().getString(locale)}
                    </#if>
    
                    <#if fieldName.getFieldReference() == 'contenido'>
                        ${fieldName.getValue().getString(locale)}
                    </#if>
                </#list>
            </#if>
        </#list>
    </#if>
    

    Regards!