How to embed WebContent in Liferay

巧了我就是萌 提交于 2019-12-13 04:24:57

问题


Is that it is possible embed web content in a template velocity? I have two web contents and I want to unite the two into a single one.

I tried this:

#set ($webcontent-id = "13054")
#set ($webcontent=$journalContentUtil.getContent($group_id, $webcontent-id,null,"$locale",$theme_display))
<div> $webcontent </div>
#set ($webcontent-id = "13065")
#set ($webcontent=$journalContentUtil.getContent($group_id, $webcontent-id,null,"$locale",$theme_display)) 
<div> $webcontent </div>

However, it displays the variable. I think I did not access the service in a webcontent.


回答1:


Web content templates do not have access to the ThemeDisplay directly. They can access request information via the $request map, which contains among other things variables from ThemeDisplay. This wiki page lists the variables that can be used from templates.

Also, when calling Liferay services from velocity templates you need to make sure that all arguments have the correct type. You can use $getterUtil to accomplish this, for example to convert a String to Long.

Here's a revised version of your example:

#set ($group_id = $getterUtil.getLong($request.theme-display.scope-group-id))
#set ($webcontent-id = "58007")
#set ($webcontent=$journalContentUtil.getContent($group_id, $webcontent-id, "", "$locale", ""))
$webcontent


来源:https://stackoverflow.com/questions/15390704/how-to-embed-webcontent-in-liferay

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!