掲示板
Page title from a link to layout
11年前 に Matías Javier Elola によって更新されました。
Page title from a link to layout
New Member 投稿: 6 参加年月日: 10/01/12 最新の投稿
Hello everybody!
I'm using the Liferay 6.1.0 bundle with JBoss 7 (under linux) and my intentions are to create different structures and templates for displaying web contents.
My problem is:
I've defined a structure with different elements and one of them is a link_to_layout and I want to display the element's title
As you can see, this is "repeatable", so, to get the information in the velocity template I have to use a foreach like the next one
So, I have to show THE_TITLE_HERE based on the $Enlace.getUrl() page, it means that I want to show the title of each page I've linked in the content.
I am linking public pages of my own community
Can you help me please?
I was looking for the solution here but one of the options is creating a new velocity variable. I guess (and hope) it's easier than that.
Thanks!
I'm using the Liferay 6.1.0 bundle with JBoss 7 (under linux) and my intentions are to create different structures and templates for displaying web contents.
My problem is:
I've defined a structure with different elements and one of them is a link_to_layout and I want to display the element's title
<dynamic-element name="Enlaces" type="link_to_layout" index-type="" repeatable="true" />
As you can see, this is "repeatable", so, to get the information in the velocity template I have to use a foreach like the next one
#foreach($Enlace in $Enlaces.getSiblings())
<a href="$Enlace.getUrl()">THE_TITLE_HERE</a>
#end
So, I have to show THE_TITLE_HERE based on the $Enlace.getUrl() page, it means that I want to show the title of each page I've linked in the content.
I am linking public pages of my own community
Can you help me please?
I was looking for the solution here but one of the options is creating a new velocity variable. I guess (and hope) it's easier than that.
Thanks!
11年前 に Chintan Akhani によって更新されました。
RE: Page title from a link to layout
Regular Member 投稿: 111 参加年月日: 08/03/13 最新の投稿
Tyr THE_TITLE_HERE = $Enlace.getTitle()
11年前 に Tejas Kanani によって更新されました。
RE: Page title from a link to layout (回答)
Liferay Master 投稿: 654 参加年月日: 09/01/06 最新の投稿
Hi Matías Javier Elola,
You'll have to use get it from layoutservice. For that you'll have to use serviceLocator.
Try below code,
And make sure you have added below property(with blank value) in portal-ext.properties. As by default you can't use serviceLocator in webcontent template. After adding below property it will allow you to use serviceLocator.
I hope this will help you.
Regards,
TK
You'll have to use get it from layoutservice. For that you'll have to use serviceLocator.
Try below code,
#set($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#foreach($Enlace in $Enlaces.getSiblings())
#if($validator.isNotNull($Enlace.getData()))
#set($currentLayout = $layoutLocalService.getLayout($getterUtil.getLong($groupId),false,$getterUtil.getLong($Enlace.getData())))
<a href="$Enlace.getUrl()">$currentLayout.getName()</a>
#end
#end
And make sure you have added below property(with blank value) in portal-ext.properties. As by default you can't use serviceLocator in webcontent template. After adding below property it will allow you to use serviceLocator.
journal.template.velocity.restricted.variables=
I hope this will help you.
Regards,
TK
11年前 に Matías Javier Elola によって更新されました。
RE: Page title from a link to layout
New Member 投稿: 6 参加年月日: 10/01/12 最新の投稿
Thanks a lot Tejas Kanani, it works!
Thank you very much for the sooner answer.
Thank you very much for the sooner answer.
10年前 に Kushal Jayswal によって更新されました。
RE: Page title from a link to layout
New Member 投稿: 18 参加年月日: 12/11/19 最新の投稿Tejas Kanani:
Hi Matías Javier Elola,
And make sure you have added below property(with blank value) in portal-ext.properties. As by default you can't use serviceLocator in webcontent template. After adding below property it will allow you to use serviceLocator.journal.template.velocity.restricted.variables=
How to add above lines into someLayout.tpl?
10年前 に Tejas Kanani によって更新されました。
RE: Page title from a link to layout
Liferay Master 投稿: 654 参加年月日: 09/01/06 最新の投稿
Which lines are you asking about the one that you've pointed ?
If you are referring to this, it will be added in portal-ext.properties
And if you asking about
What exactly you want to do in your layout ? What is you requirement ?
Thanks,
Tejas
journal.template.velocity.restricted.variables=
If you are referring to this, it will be added in portal-ext.properties
And if you asking about
#set($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
#foreach($Enlace in $Enlaces.getSiblings())
#if($validator.isNotNull($Enlace.getData()))
#set($currentLayout = $layoutLocalService.getLayout($getterUtil.getLong($groupId),false,$getterUtil.getLong($Enlace.getData())))
<a href="$Enlace.getUrl()">$currentLayout.getName()</a>
#end
#end
What exactly you want to do in your layout ? What is you requirement ?
Thanks,
Tejas
10年前 に Kushal Jayswal によって更新されました。
RE: Page title from a link to layout
New Member 投稿: 18 参加年月日: 12/11/19 最新の投稿
I wanted to get HTML title of the page and use the same to generate a dynamic class. But I got the solution.
Thanks.
Thanks.