Fórum

working with VM variables?

thumbnail
Path Finder LifeRay, modificado 11 Anos atrás.

working with VM variables?

Expert Postagens: 262 Data de Entrada: 18/09/09 Postagens 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
thumbnail
James Falkner, modificado 11 Anos atrás.

RE: working with VM variables?

Liferay Legend Postagens: 1399 Data de Entrada: 17/09/10 Postagens 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.
thumbnail
Hussain A, modificado 11 Anos atrás.

RE: working with VM variables?

Junior Member Postagens: 47 Data de Entrada: 03/04/12 Postagens Recentes
One way of setting defining and using custom VM variables is:

Step 1:

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


import com.liferay.portal.kernel.events.Action;
import com.liferay.portal.kernel.events.ActionException;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.model.User;

public class CustomAction extends Action
{
	static Logger logger = Logger.getLogger(CustomAction.class);
	
	@Override
	public void run(HttpServletRequest request, HttpServletResponse response)
			throws ActionException {
		
		
		Map<string, object> vmVariables = new HashMap<string, object>();
		
		HttpSession session	=	request.getSession(true);
		
		if(session!=null)
		{
			User user	=	(User)	session.getAttribute("USER");
			
			if(user !=null &amp;&amp; user.getJobTitle().equalsIgnoreCase("admin"))
			{
				vmVariables.put("show-control-panel", true);
			}
			else
			{
				vmVariables.put("show-control-panel", false);
			}
			request.setAttribute(WebKeys.VM_VARIABLES, vmVariables);
		}
	}
}
</string,></string,>


Step 2:

now in theme you can access this variable with " $show-control-panel "
Gouse Basha, modificado 11 Anos atrás.

RE: working with VM variables?

New Member Postagens: 10 Data de Entrada: 01/12/12 Postagens 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.
thumbnail
Anil Sunkari, modificado 11 Anos atrás.

RE: working with VM variables?

Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
For Reference : Just have a look at VelocityVariables.java in portal source!!
thumbnail
Anil Sunkari, modificado 11 Anos atrás.

RE: working with VM variables?

Expert Postagens: 427 Data de Entrada: 12/08/09 Postagens Recentes
You can get it from portal source.Downlod it from the site (or) sourceforge.net
thumbnail
Luis Mas, modificado 11 Anos atrás.

RE: working with VM variables?

Regular Member Postagens: 146 Data de Entrada: 18/05/09 Postagens Recentes
Or in http://docs.liferay.com/portal/6.1/