<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Velocity in .vm files vs. Velocity in Web Content</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=10559869" />
  <subtitle>Velocity in .vm files vs. Velocity in Web Content</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=10559869</id>
  <updated>2026-05-12T15:51:23Z</updated>
  <dc:date>2026-05-12T15:51:23Z</dc:date>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=13026518" />
    <author>
      <name>Dominik Hofbauer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=13026518</id>
    <updated>2012-03-16T17:10:27Z</updated>
    <published>2012-03-16T17:10:27Z</published>
    <summary type="html">@paro: I was using 5.2.3 for this. Maybe that has changed since LR 6&lt;br /&gt;&lt;br /&gt;@Bhupesh: I suggest to deactivate the caching so the server compiles your .vm files every time they are changed. Search the forum for more information when switching to liferay developer mode! e.g. &lt;a href="http://www.liferay.com/de/community/forums/-/message_boards/message/1582008"&gt;here&lt;/a&gt;</summary>
    <dc:creator>Dominik Hofbauer</dc:creator>
    <dc:date>2012-03-16T17:10:27Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=13016263" />
    <author>
      <name>Bhupesh Nagda</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=13016263</id>
    <updated>2012-03-16T08:30:12Z</updated>
    <published>2012-03-16T08:30:12Z</published>
    <summary type="html">Hi&lt;br /&gt;I am a bit new to this velocity technology, I want to add some images to the existing(classic) theme and work on the look and feel . I am able to edit the CSS through custom.css but when I add image through HTML in portal-normal.vm file image is not shown in the portal. i am adding the following code in  portal-normal.vm&lt;br /&gt;&lt;br /&gt;&amp;lt;img src=&amp;#34;../images/layout/top-header.jpg&amp;#34; alt =&amp;#34;Sorry Image Not Available&amp;#34;/&amp;gt;&lt;br /&gt;&lt;br /&gt;is there any specific folder in which I should keep the image file?? i tried various paths but its not working. Also do i need to change some code in the velocity file other than adding the &amp;lt;img&amp;gt; tag??</summary>
    <dc:creator>Bhupesh Nagda</dc:creator>
    <dc:date>2012-03-16T08:30:12Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12887322" />
    <author>
      <name>Paro Nasser</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12887322</id>
    <updated>2012-03-08T10:33:04Z</updated>
    <published>2012-03-08T10:33:04Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Dominik,&lt;br&gt;&lt;br&gt;somehow my JournalVmUtil.java look different, not how you discript. The JournalVmUtil is under portal-impl/src/com.liferay.portlet.journal.util ?&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;package com.liferay.portlet.journal.util;

import com.liferay.portal.kernel.xml.Element;
import com.liferay.portlet.journal.TransformException;

import java.util.List;
import java.util.Map;

/**
 * @author	  ......
 */
public class JournalVmUtil {

	public static List&amp;lt;templatenode&amp;gt; extractDynamicContents(Element parent)
		throws TransformException {

		return _instance._velocityTemplateParser.extractDynamicContents(
			null, parent);
	}

	public static String transform(
			Map&amp;lt;string, string&amp;gt; tokens, String viewMode, String languageId,
			String xml, String script)
		throws TransformException {

		return _instance._velocityTemplateParser.transform(
			null, tokens, viewMode, languageId, xml, script);
	}

	private JournalVmUtil() {
		_velocityTemplateParser = new VelocityTemplateParser();
	}

	private static JournalVmUtil _instance = new JournalVmUtil();

	private VelocityTemplateParser _velocityTemplateParser;

}&amp;lt;/string,&amp;gt;&amp;lt;/templatenode&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;there is no line with &lt;pre&gt;&lt;code&gt;velocityContext.put("variableName", variableValue)&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Thanks 4 help!&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Paro Nasser</dc:creator>
    <dc:date>2012-03-08T10:33:04Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12801674" />
    <author>
      <name>Dominik Hofbauer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12801674</id>
    <updated>2012-03-02T13:47:44Z</updated>
    <published>2012-03-02T13:47:44Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Look at the transform(..) - method in this file. There are already some lines starting with &lt;pre&gt;&lt;code&gt;velocityContext.put("variableName", variableValue)&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;You can assign any name for variableName. This can be used directly in the template by &lt;pre&gt;&lt;code&gt;$variableName&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;strong&gt;For example&lt;/strong&gt;: You declare in JournalVmUtil.java&lt;br&gt;&lt;pre&gt;&lt;code&gt;String xy = "a string";
//now lets forward this string to our template engine so we can use it in a Web Content Template
velocityContext.put("myString", xy);&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Deploy the bundle and create a new wcm template with&lt;br&gt;&lt;pre&gt;&lt;code&gt;$myString&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;br&gt;Save the template, create a web content based on this template. The page with your wcm content will return &lt;br&gt;&lt;blockquote&gt;a string&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;Edit: I'm using LR 5.2.3 for this...&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Dominik Hofbauer</dc:creator>
    <dc:date>2012-03-02T13:47:44Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12800659" />
    <author>
      <name>Paro Nasser</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=12800659</id>
    <updated>2012-03-02T13:20:22Z</updated>
    <published>2012-03-02T13:20:22Z</published>
    <summary type="html">Hi Dominik,&lt;br /&gt;&lt;br /&gt;can you please say what exactly you do or post your JournalVmUtil.java?</summary>
    <dc:creator>Paro Nasser</dc:creator>
    <dc:date>2012-03-02T13:20:22Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10716304" />
    <author>
      <name>Dominik Hofbauer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10716304</id>
    <updated>2011-09-08T12:31:19Z</updated>
    <published>2011-09-08T12:31:19Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi Guys! &lt;br&gt;&lt;br&gt;Thanks for your response. It was quite helpful to find out which options i have. In the end I simply extended the JournalVmUtil.java by 			&lt;pre&gt;&lt;code&gt;velocityContext.put("groupName", GroupLocalServiceUtil.getGroup(groupId).getName()); &lt;/code&gt;&lt;/pre&gt; to the transform method.&lt;br&gt;&lt;br&gt;Now I could do &lt;br&gt;&lt;pre&gt;&lt;code&gt;$groupName&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;to get the community name in wcm with velocity &lt;img alt="emoticon" src="@theme_images_path@/emoticons/cool.gif"&gt;&lt;br&gt;&lt;br&gt;cheers&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Dominik Hofbauer</dc:creator>
    <dc:date>2011-09-08T12:31:19Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10561347" />
    <author>
      <name>David H Nebinger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10561347</id>
    <updated>2011-08-24T14:14:03Z</updated>
    <published>2011-08-24T14:14:03Z</published>
    <summary type="html">In order to use velocity, you give it a template file and also properties (beans) to use when processing the template.  So you&amp;#39;re going to be limited in your template to the beans that are defined.&lt;br /&gt;&lt;br /&gt;It&amp;#39;s quite possible that although you cannot access the value directly as the theme templates can, that you might be able to get there by navigating through the beans that are available.</summary>
    <dc:creator>David H Nebinger</dc:creator>
    <dc:date>2011-08-24T14:14:03Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10560173" />
    <author>
      <name>Oliver Bayer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10560173</id>
    <updated>2011-08-24T13:48:12Z</updated>
    <published>2011-08-24T13:48:12Z</published>
    <summary type="html">Hi Dominik,&lt;br /&gt;&lt;br /&gt;there are two java classes in which you define which data is accessible in vm by using a given parameter name.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;VelocityVariables (all variables defined here are accessible in theme vm&amp;#39;s)&lt;/li&gt;&lt;li&gt;JournalVmUtil (variables which can be used inside journal templates)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;The variable &amp;#34;groupId&amp;#34; should be set inside journal templates. You should be able to use it to retrieve the group object and then output the group name.&lt;br /&gt;&lt;br /&gt;HTH Oli</summary>
    <dc:creator>Oliver Bayer</dc:creator>
    <dc:date>2011-08-24T13:48:12Z</dc:date>
  </entry>
  <entry>
    <title>Velocity in .vm files vs. Velocity in Web Content</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10559868" />
    <author>
      <name>Dominik Hofbauer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=10559868</id>
    <updated>2011-08-24T12:58:15Z</updated>
    <published>2011-08-24T12:58:15Z</published>
    <summary type="html">I have a question to using velocity in liferay. There are two (or possibly more) ways to use velocity in liferay.&lt;br /&gt; &lt;ul&gt;&lt;li&gt;Velocity in .vm files for the main theme layout&lt;/li&gt;&lt;li&gt;Velocity in Web Content Templates to create Web Content forms&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;My need is to get the Community Name within a web content display. So I found $community_name in the theme/classic/templates/navigation.vm file. When trying to reuse the variable within a Web Content Template it will not be parsed. What am I doing wrong or is this a misunderstanding with a velocity context. Isn&amp;#39;t it portal wide the same?&lt;br /&gt;&lt;br /&gt;Can somebody explain me please or is there another way to display the community name within a web content display?&lt;br /&gt;&lt;br /&gt;Thanx in advance...</summary>
    <dc:creator>Dominik Hofbauer</dc:creator>
    <dc:date>2011-08-24T12:58:15Z</dc:date>
  </entry>
</feed>
