Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Path Finder LifeRay
working with VM variables?
1 de Dezembro de 2012 02:07
Resposta

Path Finder LifeRay

Ranking: Expert

Mensagens: 262

Data de entrada: 18 de Setembro de 2009

Mensagens recentes

Hi All,

I'd like to know how to work with the velocity variables?
While trying to work with themes i have seen the templates folder, and i came to know that vm files was written in velocity mark up language.

Now my question are:

where these variables are defined, for example($nav_item,$nav_item.getURL())etc.,not specifically about nav, variables like these in the whole vm files.

how to get these variables?if i need to define new variables where i can set?

is there any documentation/tutorial available for creating the vm files?please guide me

regards
path
James Falkner
RE: working with VM variables?
1 de Dezembro de 2012 03:14
Resposta

James Falkner

LIFERAY STAFF

Ranking: Liferay Legend

Mensagens: 1253

Data de entrada: 17 de Setembro de 2010

Mensagens recentes

Path Finder LifeRay:
Hi All,

I'd like to know how to work with the velocity variables?
While trying to work with themes i have seen the templates folder, and i came to know that vm files was written in velocity mark up language.

Now my question are:

where these variables are defined, for example($nav_item,$nav_item.getURL())etc.,not specifically about nav, variables like these in the whole vm files.

how to get these variables?if i need to define new variables where i can set?

is there any documentation/tutorial available for creating the vm files?please guide me

regards
path


Variables are already available to your template files. See this wiki page for details.
Atif Hussain
RE: working with VM variables?
1 de Dezembro de 2012 10:16
Resposta

Atif Hussain

Ranking: Junior Member

Mensagens: 47

Data de entrada: 3 de Abril de 2012

Mensagens recentes

One way of setting defining and using custom VM variables is:

Step 1:

Make a variable " show-control-panel " of boolean type

 1
 2import com.liferay.portal.kernel.events.Action;
 3import com.liferay.portal.kernel.events.ActionException;
 4import com.liferay.portal.kernel.util.WebKeys;
 5import com.liferay.portal.model.User;
 6
 7public class CustomAction extends Action
 8{
 9    static Logger logger = Logger.getLogger(CustomAction.class);
10   
11    @Override
12    public void run(HttpServletRequest request, HttpServletResponse response)
13            throws ActionException {
14       
15       
16        Map<String, Object> vmVariables = new HashMap<String, Object>();
17       
18        HttpSession session    =    request.getSession(true);
19       
20        if(session!=null)
21        {
22            User user    =    (User)    session.getAttribute("USER");
23            
24            if(user !=null && user.getJobTitle().equalsIgnoreCase("admin"))
25            {
26                vmVariables.put("show-control-panel", true);
27            }
28            else
29            {
30                vmVariables.put("show-control-panel", false);
31            }
32            request.setAttribute(WebKeys.VM_VARIABLES, vmVariables);
33        }
34    }
35}


Step 2:

now in theme you can access this variable with " $show-control-panel "
Gouse Basha
RE: working with VM variables?
3 de Dezembro de 2012 01:48
Resposta

Gouse Basha

Ranking: New Member

Mensagens: 10

Data de entrada: 30 de Novembro de 2012

Mensagens recentes

Path Finder LifeRay:
Hi All,

I'd like to know how to work with the velocity variables?
While trying to work with themes i have seen the templates folder, and i came to know that vm files was written in velocity mark up language.

Now my question are:

where these variables are defined, for example($nav_item,$nav_item.getURL())etc.,not specifically about nav, variables like these in the whole vm files.

how to get these variables?if i need to define new variables where i can set?

is there any documentation/tutorial available for creating the vm files?please guide me

regards
path


You can set your variables in init_custom.vm file.
Anil Sunkari
RE: working with VM variables?
3 de Dezembro de 2012 03:24
Resposta

Anil Sunkari

Ranking: Expert

Mensagens: 397

Data de entrada: 11 de Agosto de 2009

Mensagens recentes

For Reference : Just have a look at VelocityVariables.java in portal source!!
Anil Sunkari
RE: working with VM variables?
11 de Dezembro de 2012 21:44
Resposta

Anil Sunkari

Ranking: Expert

Mensagens: 397

Data de entrada: 11 de Agosto de 2009

Mensagens recentes

You can get it from portal source.Downlod it from the site (or) sourceforge.net
Luis Mas
RE: working with VM variables?
11 de Dezembro de 2012 08:14
Resposta

Luis Mas

Ranking: Regular Member

Mensagens: 146

Data de entrada: 18 de Maio de 2009

Mensagens recentes

Or in http://docs.liferay.com/portal/6.1/