How do I know if a page is private or public in a Liferay theme?
As the title says ... How do you know if a page is private or public? I need to implement some logic in the speed file from my custom theme for personal pages only.
I found this page Accessing Objects with Velocity and it seems very useful, but I need help with the API because I don't know which utility class has a method for what I'm looking for.
I thought there was a workaround whereby my condition has a theme property, but I don't want to depend on the admin user
thank
source to share
Artem Khojoyan to answer this question.
But I would like to add more information.
A page in liferay is represented by an object Layout
. The theme template supports Layout
as well as many other objects in the theme template that you can check in class VelocityVariablesImpl
. You can check for type assertions velocityContext.put("key","value");
, where key
is a variable that you can use in a speed pattern like $key
.
Since it $layout
is nothing but an object Layout
, you can use all methods of an open instance of that Layout
object at speed.
For each request $layout
, the topic displays the current page to be loaded.
So, you can do the following in yours portal_normal.vm
or init_custom.vm
whatever else *.vm
you have in your topic:
#if($layout.isPublicLayout())
#*.. do something if it is public ...*#
#else
#*.. do something if it is private ...*#
#end
Hope it helps.
source to share
you can also use:
#if($layout.isPublicLayout())
#*.. This is public ...*#
#elseif ($layoutmodel.isprivatelayout())
#*.. This is private ...*#
#end
for more details on other methods for Liferay Interface Layout
source to share