简体   繁体   English

在Liferay中重载Web内容Portlet

[英]Overloading web content Portlet in Liferay

In Liferay, when you add a web content to a page, a Portlet is created and you can choose the web content that will be displayed (when logged as admin), and you can choose some parameters (rights to view the content, share...). 在Liferay中,当您将Web内容添加到页面时,会创建一个Portlet,您可以选择将要显示的Web内容(以admin身份登录时),还可以选择一些参数(查看内容和共享的权限)。 ..)。 I would like to create a Portlet that overloads this Portlet, to allow the admin to choose his / her web content with custom parameters. 我想创建一个可重载此Portlet的Portlet,以允许管理员使用自定义参数选择其Web内容。

Does anyone know how this could be done ? 有谁知道该怎么做? Thanks ! 谢谢 !

  1. First idea which came to my mind is to hook default Web Content Display Portlet This would allow you to add some custom business logic to this portlet and not need to implement all you already get from original one. 我想到的第一个想法是挂接默认的Web内容显示Portlet,这将使您可以向此Portlet添加一些自定义业务逻辑,而无需实现从原始Portlet获得的所有功能。 Still this will much depends on how much your new features you want to add, are complex. 尽管如此,这在很大程度上取决于您要添加的新功能有多少复杂。

    As you have said, you are beginner, so here are some hints, how to start up with hook creation: 如您所说,您是新手,所以这里有一些提示,介绍如何开始创建钩子:

  2. Another idea is to use maven war overlay which you can read about more under http://java.dzone.com/articles/mavens-war-overlay-what-are 另一个想法是使用Maven战争叠加层 ,您可以在http://java.dzone.com/articles/mavens-war-overlay-what-are下了解更多信息

As you say you're a beginner, I'd suggest to create your own portlet that is independent of Liferay's portlets. 正如您所说的,您还是一个初学者,我建议您创建一个独立于Liferay的portlet的portlet。 You can use Liferay's API to get the article you'd like and its content, while implementing your own functionality to filter out the content you like. 您可以使用Liferay的API获取所需的文章及其内容,同时实现自己的功能以过滤出所需的内容。

The reason I'm suggesting a custom portlet is: Liferay's portlets must be as generic as possible, to match as many usecases as possible. 我建议使用自定义portlet的原因是:Liferay的portlet必须尽可能通用,以匹配尽可能多的用例。 Thus there are lots of conditionals that you won't need (and won't need to understand) in the implementation. 因此,在实现中有很多您不需要(也不需要理解)的条件。 If you have some narrow non-generic requirements to have an alternative behavior, you're easier off implementing exactly those requirements rather than adding to the generic, highly conditional UI. 如果您有一些狭窄的非通用需求以具有替代行为,那么您完全可以完全实现这些需求,而不是添加到通用的,高度条件的UI中。 Plus, you might want to keep the original UI for other purposes. 另外,您可能想要保留原始UI以便用于其他目的。 If you make a mistake in your own implementation, the original Web Content Display Portlet would still continue to work. 如果您在自己的实现中出错,原始的Web Content Display Portlet仍将继续工作。

That being said, you might also look at the AssetPublisher portlet. 话虽如此,您也可以查看AssetPublisher Portlet。 It's the swiss army knife of content management and might already do what you want (and a lot more). 它是内容管理的瑞士军刀,可能已经做了您想要做的(还有更多)。 This takes criteria and will evaluate them at runtime, displaying matching articles (or other content types). 这将采用标准,并将在运行时评估它们,显示匹配的文章(或其他内容类型)。

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

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