在Portlet Liferay 6.1中呈现Liferay页面URL [英] rendering Liferay page URLs inside of portlets Liferay 6.1
问题描述
我是Liferay的新手,我非常肯定这非常容易做到:使用速度标记,我希望能够生成Liferay网站内页面的链接,并将它们嵌入到我在不同页面上的portlet中.
I'm new to liferay and I'm almost positive this is blazingly simple to do: Using velocity markup, I want to be able to generate links to pages within my Liferay website and embed them inside of my portlets on different pages.
我对如何完成工作有一个模糊的想法,因此我搜寻了一下它是否会张贴在某个地方,但是我找不到任何东西.顺便说一句,我想将我想出的任何代码放入portlet的view.jsp中.我会在这里使用速度标记,但我不认为(不确定)是否可以在jsp中使用它.
I have a vague idea of how it might be done so I searched around figuring it would be posted somewhere, but I can't find anything on it. Incidentally, I want to put whatever code I come up with inside the view.jsp of the portlet. I would use velocity markup here but I don't think (don't know for sure) if that is allowed inside of a jsp.
如果您需要更多信息来答复,请告诉我.
Please let me know if you need more information to respond.
推荐答案
我会在这里使用速度标记,但是我不认为(不确定)是否可以在jsp中使用它.
I would use velocity markup here but I don't think (don't know for sure) if that is allowed inside of a jsp.
为什么要在JSP(view.jsp
)中使用Velocity标记?除了认为您的速度确实很棒之外,我看不出这样做有什么好处.
Why would you want to use Velocity mark-up inside a JSP (view.jsp
)? I don't see any advantages in doing that apart from the argument that you are really great at velocity.
尽管这是一个链接,它将为您提供帮助将速度嵌入JSP内.
Though here is a link that would help you embed velocity inside of JSP.
注意:我认为在JSP中将速度嵌入portlet中不是一个好习惯
在JSP中:
- 您将需要一个
Layout
对象,您可以在com.liferay.portal.util.PortalUtil
(例如getLayoutFriendlyURL
或getLayoutFullURL
等)来构建URL.
- You will need a
Layout
object which you can get with the help of static methods inLayoutLocalServiceUtil
. - After you get the Layouts, you can use the static methods of
com.liferay.portal.util.PortalUtil
likegetLayoutFriendlyURL
orgetLayoutFullURL
etc to build the URL.
在VM中(在主题中为*.vm
文件):
您可以按照JSP中提到的所有相同步骤进行操作.您需要做的是:
In VM (these would be *.vm
files in themes):
You can follow all the same steps as mentioned in JSP. The things you would need to do that are:
-
可以使用以下代码找到
-
LayoutLocalService
的实例(摘自该 answer ):
Instance of
LayoutLocalService
, can be found out by using the following code (taken from this answer):
#set($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
现在您可以使用速度变量$layoutLocalService
调用用于获取布局的服务方法.
now you can use the velocity variable $layoutLocalService
to make calls to service methods for getting the layouts.
然后,您可以使用主题中*.vm
文件可用的变量$portalUtil
来调用PortalUtil
类的方法.
Then you can call methods of PortalUtil
class by using the variable $portalUtil
available for *.vm
files in themes.
您可以检出以下文件以了解更多详细信息(如果您有兴趣):
You can check-out the following files for more details (if you are interested):
docroot/html/themes/_unstyled/templates/init.vm
, this contains all the velocity variables available in themes. Variables of interest might be$theme
,$theme_display
,$layout
,$navItems
.docroot/html/themes/_unstyled/templates/portlet.vm
, this file is a template to display the individual portlets.docroot/html/themes/_unstyled/templates/navigation.vm
, contains code for displaying the navigation menu with page links.docroot/html/themes/_unstyled/templates/portal_normal.vm
, this file represents a page-template in liferay and this contains the other files likenavigation.vm
&portlet.vm
.
这篇关于在Portlet Liferay 6.1中呈现Liferay页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!