Foren
Page title from a link to layout
Matías Javier Elola, geändert vor 11 Jahren.
Page title from a link to layout
New Member Beiträge: 6 Beitrittsdatum: 12.01.10 Neueste Beiträge
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!
Chintan Akhani, geändert vor 11 Jahren.
RE: Page title from a link to layout
Regular Member Beiträge: 111 Beitrittsdatum: 13.03.08 Neueste Beiträge
Tyr THE_TITLE_HERE = $Enlace.getTitle()
Tejas Kanani, geändert vor 11 Jahren.
RE: Page title from a link to layout (Antwort)
Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
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
Matías Javier Elola, geändert vor 11 Jahren.
RE: Page title from a link to layout
New Member Beiträge: 6 Beitrittsdatum: 12.01.10 Neueste Beiträge
Thanks a lot Tejas Kanani, it works!
Thank you very much for the sooner answer.
Thank you very much for the sooner answer.
Kushal Jayswal, geändert vor 10 Jahren.
RE: Page title from a link to layout
New Member Beiträge: 18 Beitrittsdatum: 19.11.12 Neueste BeiträgeTejas 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?
Tejas Kanani, geändert vor 10 Jahren.
RE: Page title from a link to layout
Liferay Master Beiträge: 654 Beitrittsdatum: 06.01.09 Neueste Beiträge
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
Kushal Jayswal, geändert vor 9 Jahren.
RE: Page title from a link to layout
New Member Beiträge: 18 Beitrittsdatum: 19.11.12 Neueste Beiträge
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.