Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nikos Kapatos
Velocity Variables and Methods list
May 28, 2009 5:50 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

Where I can find a full list of variables and methods used from liferay velocity?

I've found an html page having some of them but i couldn't find the var "$user " or the method "getMyPlaces()" for example.

I've google it in any possible way and searched the forums lot of time with no luck.
Lari Tuominen
RE: Velocity Variables and Methods list
May 28, 2009 6:29 AM
Answer

Lari Tuominen

Rank: Expert

Posts: 283

Join Date: November 7, 2007

Recent Posts

Check from Liferay trunk: VelocityVariables.java (if you don't have trunk you can also find it from google).

Also check this article from wiki: http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Which+classes+are+automatically+available+from+a+velocity+template

- Lari
Nikos Kapatos
RE: Velocity Variables and Methods list
May 28, 2009 8:10 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

Thanx for your time and help.

From the link u provided

http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Which+classes+are+automatically+available+from+a+velocity+template

says to look the "portal-impl/src/com/liferay/portal/velocityVelocityVariables.java " but I can't find where this file is.

I searched all folders one by one and i found the porta-impl.jar.

The problem is that the path is "portal-impl/com/liferay/portal/velocityVelocityVariables.class" (no src/) and when i try to open it, it says "cannot open, no sources".

Anyway from that page it has a link to
"http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/How%20To%20Access%20Objects%20From%20A%20Velocity%20Template"

Which has all (not sure if all cause i can't check it) objects.

Now there r 2 problems

First problem is that in the first link it has an example " $layout.getName() ".
The problem in this is the .getName() now that we have a complete (I hope) list of objects.
Based on the example we know that there is a ".getName()" but is there something else?
Like ".setName()", or ".helloWorld()".
If yes is there a way to have a list?
R these for the "$layout" only?
Can be used with other objects?

The second problem is that after all the googling i found a page named "Theme Variables Documentation" which unfortunately i didn't kept the url but i have a print of it.

In this page under the "User Specific variables" it has "$user_login_ip", which is something I can't find in the second link with all the objects, and unfortunately this makes things even more complicated than they r now.

* NOTE *
1st link is "http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Which+classes+are+automatically+available+from+a+velocity+template"

2nd link is "http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/How%20To%20Access%20Objects%20From%20A%20Velocity%20Template"

***********

Thanx for the brave ones who read all this and double thanx those who will dare to answer
Amos Fong
RE: Velocity Variables and Methods list
May 28, 2009 10:57 AM
Answer

Amos Fong

LIFERAY STAFF

Rank: Liferay Legend

Posts: 1898

Join Date: October 7, 2008

Recent Posts

Hey Nikos,

You'll want to download the Liferay source code so it's easier to research this further. In the first example, layout is a java class, and if you look in the source code, you'll see all the methods available to it. (ie setName())

For your second issue, that variable is set in init.vm. You should be able to look at this file in docroot/html/themes/unstyled/templates

These are basically preset variables for use only in themes.
Nikos Kapatos
RE: Velocity Variables and Methods list
May 28, 2009 12:11 PM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

And finally the puzzle solved

Thanx both of u for your time and help.

emoticon
Victor Zorin
RE: Velocity Variables and Methods list
June 4, 2009 10:14 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

It looks like there is always a bit of effort required to get information related to velocity variables. Various manuals are not always up to date.

To make external developers life a bit easier, I have moved own Velocity Variables Explorer from private to public manual pages.
For security reasons, you will not be able to see actual values of those variables without being logged in, but it still produces a lot of useful information. At least it is always up-to-date.
Nikos Kapatos
RE: Velocity Variables and Methods list
June 23, 2009 5:59 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

Victor Zorin:
It looks like there is always a bit of effort required to get information related to velocity variables. Various manuals are not always up to date.

To make external developers life a bit easier, I have moved own Velocity Variables Explorer from private to public manual pages.
For security reasons, you will not be able to see actual values of those variables without being logged in, but it still produces a lot of useful information. At least it is always up-to-date.


OMG

I just saw your post and my friend and this is unbelievable. Many many thanx for that link and I believe lot of ppl will be happy with that link.

Thanx again emoticon
Victor Zorin
RE: Velocity Variables and Methods list
June 23, 2009 1:33 PM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

Thanks Nikos. That's very encouraging. We make sure that it is improving in terms of usability and data access.
Another type of explorer will be moved into public spot soon.
Thomas Kellerer
RE: Velocity Variables and Methods list
October 15, 2009 4:10 AM
Answer

Thomas Kellerer

Rank: Expert

Posts: 377

Join Date: June 9, 2008

Recent Posts

Victor Zorin:
To make external developers life a bit easier, I have moved own Velocity Variables Explorer from private to public manual pages.

Thanks, very nice.

Unfortunately it does not list all Velocity variables. Inside a theme there are e.g. $full_templates_path, $nav_items, $css_main_file, $show_home, $show_page_settings, and a lot more

Are you planning to include those as well at some point in time?
Nikos Kapatos
RE: Velocity Variables and Methods list
October 16, 2009 12:23 AM
Answer

Nikos Kapatos

Rank: Junior Member

Posts: 57

Join Date: November 11, 2008

Recent Posts

Hi Thomas

These r custom variables that can be found in init.vm file inside your webapps/ROO/\html/themes/_unstyled/templates folder.

EDIT: Not sure if the path is the same for all packages but this path is for tomcat bundle
Victor Zorin
RE: Velocity Variables and Methods list
October 20, 2009 1:47 AM
Answer

Victor Zorin

Rank: Liferay Legend

Posts: 1177

Join Date: April 14, 2008

Recent Posts

Thanks Thomas, well add those items by the end of this week.
Also, we expect to push to public use another explorer portlet, this one will provide digging capability for an entire set of Liferay Services API. Hope it will also be very useful.
Brandt Solovij
RE: Velocity Variables and Methods list
January 11, 2013 10:29 AM
Answer

Brandt Solovij

Rank: New Member

Posts: 14

Join Date: March 23, 2012

Recent Posts

@Nikos Kapatos --- SUPER HELPFUL POST!!!!

I was scratching my head where some of the variables and methods originated and your post helped me a lot.

Topic necromancy aside, I am curious on performance issues with using logic within the vm templating space? Does anyone have any insight on how much or how little active programming should be entertained with the velocity templates? Thanks in advance
Ram Mugalipoo
RE: Velocity Variables and Methods list
July 6, 2015 1:34 PM
Answer

Ram Mugalipoo

Rank: New Member

Posts: 5

Join Date: July 2, 2015

Recent Posts

I found a link http://www.liferay.com/community/wiki/-/wiki/Main/CMS+Template+%28Velocity%29#section-CMS+Template+(Velocity)-From+VelocityVariables

where the velocity variables are listed out.