Foros de discusión

Page title from a link to layout

thumbnail
Matías Javier Elola, modificado hace 11 años.

Page title from a link to layout

New Member Mensajes: 6 Fecha de incorporación: 12/01/10 Mensajes recientes
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

<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, modificado hace 11 años.

RE: Page title from a link to layout

Regular Member Mensajes: 111 Fecha de incorporación: 13/03/08 Mensajes recientes
Tyr THE_TITLE_HERE = $Enlace.getTitle()
thumbnail
Tejas Kanani, modificado hace 11 años.

RE: Page title from a link to layout (Respuesta)

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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,


#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
thumbnail
Matías Javier Elola, modificado hace 11 años.

RE: Page title from a link to layout

New Member Mensajes: 6 Fecha de incorporación: 12/01/10 Mensajes recientes
Thanks a lot Tejas Kanani, it works!
Thank you very much for the sooner answer.
thumbnail
Kushal Jayswal, modificado hace 10 años.

RE: Page title from a link to layout

New Member Mensajes: 18 Fecha de incorporación: 19/11/12 Mensajes recientes
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?
thumbnail
Tejas Kanani, modificado hace 10 años.

RE: Page title from a link to layout

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
Which lines are you asking about the one that you've pointed ?
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
thumbnail
Kushal Jayswal, modificado hace 9 años.

RE: Page title from a link to layout

New Member Mensajes: 18 Fecha de incorporación: 19/11/12 Mensajes recientes
I wanted to get HTML title of the page and use the same to generate a dynamic class. But I got the solution.

Thanks.