如何在Liferay中嵌入WebContent [英] How to embed WebContent in Liferay

查看:99
本文介绍了如何在Liferay中嵌入WebContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以以模板速度嵌入Web内容? 我有两个Web内容,我想将两者合并为一个.

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.

我尝试过:

#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>

但是,它显示变量.我想我没有在Web内容中访问该服务.

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

推荐答案

Web内容模板无法直接访问ThemeDisplay.他们可以通过$ request映射访问请求信息,该映射除其他外还包含ThemeDisplay中的变量.

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.

此外,从速度模板调用Liferay服务时,您需要确保所有参数都具有正确的类型.您可以使用$ getterUtil完成此操作,例如将String转换为Long.

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

这篇关于如何在Liferay中嵌入WebContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆