0

I have defined:

  • A structure
  • Two or mote templates associated to the structure (full content, short block abstract, ...)
  • A web content in the given structure

in a different template I have the functions to gather the reference to my article; I wish to render an article with a given template.

...
#set( $templateId = 27121)
#set ($DDMTemplateLocalService = $serviceLocator.findService("com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalService"))
#set( $ddmTemplate = $DDMTemplateLocalService.getTemplate($templateId))
#if( ( $articleId != $reserved-article-id.data ) )
    #set( $webContent = $journalContentUtil.getContent( $groupId, $articleId, $ddmTemplate.getPrimaryKey(), "view", "$locale", $xmlRequest ) )
    #if ( $webContent )
    <div>${webContent}</div>
    #else
    <div>Cannot use $templateName</div>
    #end
#end

... the variable $webContent is always empty .

lrkwz
  • 6,105
  • 3
  • 36
  • 59

2 Answers2

0

The reply comes from liferay forum https://www.liferay.com/community/forums/-/message_boards/view_message/45238697

"Method getContent of JournalContentUtil gets ddmTemplateKey as a third parameter, not ddmTemplateId. These are two different properties of DDMTemplate. If you use $ddmTemplate.getTemplateKey() instead of $ddmTemplate.getPrimaryKey(), it should work (of course if there are no other bugs)."

thanks to Krzysztof Gołębiowski

lrkwz
  • 6,105
  • 3
  • 36
  • 59
-1

When you are outside of a Velocity tag, you need to use ${webContent}. The same goes for Freemarker.

Ben VonDerHaar
  • 281
  • 1
  • 4
  • 15