Foros de discusión

About portlet.vm

Edward Cruise, modificado hace 12 años.

About portlet.vm

New Member Mensajes: 9 Fecha de incorporación: 3/02/11 Mensajes recientes
Hello guys,
I'm developing a new liferay theme and I want to customize portlet layout, so I modified portlet.vm template file, those presents in _diff directory.
In init_custom.vm I added a dummy source code that discover if user logged in is Administrator or other profile, setting up a velocity variable $isAdmin true if
user is Administrator, false otherwise.

From portal_normal.vm I can retrieve such a variable and so I'm able to write dynamic code. Same thing I would do from portlet.vm, but I can't retrieve this variable
it seems that scope is not the same of portal_normal.vm.

I apologize if my question is trivial, but I was wondering if I'm missing something.

Why can't I access such a variable ? Maybe conceptually is wrong to put such a code into this file ?

Thanks in advance,
regards edcruise.
thumbnail
David H Nebinger, modificado hace 12 años.

RE: About portlet.vm

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Portlet.vm is actually processed by a separate instance of Velocity, not the same instance that is used by portal_normal.vm. It has it's own velocity context that does not include the context used during the processing of portal_normal.vm, and therefore the variable will not be visible.

Besides, I think changing the portlet wrapper if you're admin vs not is an unusual case. The portlet decorations (i.e. the options, max, min, and close) are not usually determined at an admin level but at an owner level. If you, say, did not have the options icon, I could drop a portlet on my personal page but if I'm not an admin I could not configure it.

Anything like this you'd actually use permissions on the portlet to control anyway, and not some random fact of whether a user is admin or not.