简体   繁体   English

从portlet内部访问Liferay Web内容?

[英]Accessing Liferay web content from inside a portlet?

I have a Struts portlet being used in a Liferay Portal environment. 我在Liferay Portal环境中使用了Struts portlet。 I have been localizing my resource strings using standard resource files so far. 到目前为止,我一直在使用标准资源文件本地化我的资源字符串。 I can access the message bundle from my portlet using the <bean:message> tag, and it works great. 我可以使用<bean:message>标签从我的portlet访问消息包,它运行良好。 So for example, in a form I might have the following label defined in my JSP file. 因此,例如,在一个表单中,我可能在我的JSP文件中定义了以下标签。

...
<label for="firstname">
    <bean:message key='labels.firstname'/>
</label>
...

This works fine for short strings that don't change after compile time. 这适用于在编译时间后不会更改的短字符串。 I can localize my strings properly, compile my portlet, and it just works. 我可以正确地本地化我的字符串,编译我的portlet,它只是工作。

Problem: I have a requirement to allow portal content authors to modify content used in my portlet, on-the-fly, after compilation. 问题:我需要允许门户内容作者在编译后即时修改我的portlet中使用的内容。 My first thought was to use Liferay's web content system, so content authors could create localized web content pieces that I could access from my portlet's JSP files. 我的第一个想法是使用Liferay的Web内容系统,因此内容作者可以创建我可以从我的portlet的JSP文件访问的本地化Web内容片段。

Question: Is a way to access Liferay web content from inside my portlet? 问题:是否可以从我的portlet中访问Liferay Web内容?

There is a tag from the liferay-ui that displays the content of a CMS "article" : liferay-ui中有一个标签,显示CMS“文章”的内容:

<liferay-ui:journal-article articleId="YOUR_ARTICLE_ID" groupId="<%= groupId %>" />

It can be used for example to display variable "terms of use", as explained here 它可以用于例如显示变量“使用条款”,如这里所解释的

You can also find some inspiration in the content display portlet jsps for a more flexible approach. 您还可以在内容显示portlet jsps中找到一些灵感,以获得更灵活的方法。

Have you looked at the Content Management System included in liferay? 您是否查看过liferay中包含的内容管理系统? That could be the answer to your need. 这可能是您需要的答案。 It would allow content authors to create content in the CMS and then you could write template JSPs that would pull in the content from there. 它允许内容作者在CMS中创建内容,然后您可以编写模板JSP,从中提取内容。

Liferay CMS Liferay CMS

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM