Fórum

$request.attributes.LAYOUT.name doesn't work?

Chee Chun Liew, modificado 13 Anos atrás.

$request.attributes.LAYOUT.name doesn't work?

New Member Mensagem: 1 Data de Entrada: 21/04/10 Postagens Recentes
I'm developing structure/template in 5.2 SP4, was trying to get page name where the Web Content is added.

Search around and found out one of the way is digging in $request. After examine the values store in $request, $request.attributes.LAYOUT.name might be a way to pull it off. But I was unable to make it work, $request.attributes.LAYOUT returns the layout object though.

Tried getName(), name(), get("name") too, but no prevail, am I doing anything wrong? Or perhaps there's a different way to get the page name?

Thanks.
thumbnail
Anil Kumar Sunkari, modificado 13 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
Hi Chee,

I'm developing structure/template in 5.2 SP4, was trying to get page name where the Web Content is added.

Search around and found out one of the way is digging in $request. After examine the values store in $request, $request.attributes.LAYOUT.name might be a way to pull it off. But I was unable to make it work, $request.attributes.LAYOUT returns the layout object though.

Tried getName(), name(), get("name") too, but no prevail, am I doing anything wrong? Or perhaps there's a different way to get the page name?



Page name nothing but Layout name.you can achieve by this way. Try this in Template

#set ($theme_display = $themeDisplay)
#set( $pageName = $themeDisplay.getLayout().getName())

$pageName ..........by printing this you can get current pageName.

Thanks
Anil
Jody Braaten, modificado 13 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

New Member Postagens: 5 Data de Entrada: 13/11/08 Postagens Recentes
Hello,

I am having the same problem (5.2.3), and the above solution isn't working for me. Adding $request.attributes.LAYOUT to my template does display the layout values; however, I'm trying to get at the value for the layout field named 'column-2'. Here's the display of my LAYOUT data:

LAYOUT: {plid=99999, groupId=99999, companyId=99999, privateLayout=true, layoutId=999, parentLayoutId=1, name=Assets, title=, description=, type=portlet, typeSettings=layout-template-id=my template 118_INSTANCE_8Cs6_column-1=118_INSTANCE_8Cs6, 118_INSTANCE_Csu6_column-1=118_INSTANCE_Csu6, column-2=56_INSTANCE_p7Tc,56_INSTANCE_7uwL,56_INSTANCE_Pdv5 , hidden=false, friendlyURL=/assets, iconImage=false, iconImageId=0, themeId=, colorSchemeId=, wapThemeId=, wapColorSchemeId=, css=, priority=6, dlFolderId=0}

I have tried so MANY combinations of getting just the column-2 field value that I'm now feeling pretty dense... emoticon I really need to have this done like 'yesterday', so I'd very much appreciate any assistance.

Thanks in advance.
Guillaume B, modificado 13 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

Junior Member Postagens: 35 Data de Entrada: 15/06/10 Postagens Recentes
Same issue with Liferay 6.05.

Can't get the friendly url...
thumbnail
Felix J Christy, modificado 13 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

Regular Member Postagens: 111 Data de Entrada: 26/08/09 Postagens Recentes
Hi,

To access the layout object, you can take the layout id from the following code, and then call the layout service and access the full object.

##take layout id
#set ($layoutId = $request.get("theme-display").get("plid"))

##get the service for layout
#set($layoutService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))

##convert the layout id into long
#set ($layoutLong = $getterUtil.getLong($layoutId))

##take a layout object
#set($layout = $layoutService.getLayout($layoutLong))


To use service locator in vm, you need to override the following property in portal-ext.properties.

journal.template.velocity.restricted.variables=

Thanks,
Felix
Bradley Wood, modificado 13 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

thumbnail
Sagar A Vyas, modificado 12 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

Liferay Master Postagens: 679 Data de Entrada: 17/04/09 Postagens Recentes
Hi All,

#set ($layoutId = $request.attributes.LAYOUT)) --> This line working fine with template.

But

#set ($layoutId = $request.attributes.LAYOUT.anyproperties)) --- Does not working emoticon

Can anyone justify ? is this a bug in LIferay 6 sp1.

Thanks,
Sagar Vyas
thumbnail
Aldo De Vleeschauwer, modificado 12 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

Junior Member Postagens: 35 Data de Entrada: 09/03/11 Postagens Recentes
Looks like $request.attributes.LAYOUT is just a string. So you cannot call any properties on it.
Tomasz Sabała, modificado 10 Anos atrás.

RE: $request.attributes.LAYOUT.name doesn't work?

New Member Postagens: 3 Data de Entrada: 08/07/13 Postagens Recentes
A workaround created by me (needed to quickly update one template so it's not elegant yet functional) is:


##get the whole LAYOUT section
#set ($param_name = "$request.attributes.LAYOUT")

##cut the first part we are left with "ourValue, nextParam=blabla, (...)}"
#set ($param_name = $param_name.replaceFirst('.*nameOfTheParameter=', ''))

##cut the last part and leave only the value of the param
#set ($param_name = $param_name.replaceFirst(',.*', ''))