<?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 and WebContent (CMS)</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=11404583" />
  <subtitle>Velocity and WebContent (CMS)</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=11404583</id>
  <updated>2026-05-21T17:47:03Z</updated>
  <dc:date>2026-05-21T17:47:03Z</dc:date>
  <entry>
    <title>RE: Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11458950" />
    <author>
      <name>Deb Troxel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11458950</id>
    <updated>2011-11-14T17:43:13Z</updated>
    <published>2011-11-14T17:43:13Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Rubén is correct.  Remove serviceLocator from the restricted list in your portal-ext.properties like this:&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;journal.template.velocity.restricted.variables=
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;Of course this opens up much more functionality to anyone with permissions to edit a template, so you would want to consider the security implications in a production environment.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Deb Troxel</dc:creator>
    <dc:date>2011-11-14T17:43:13Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11453783" />
    <author>
      <name>Rubén García Tamayo</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11453783</id>
    <updated>2011-11-14T11:49:50Z</updated>
    <published>2011-11-14T11:49:50Z</published>
    <summary type="html">I&amp;#39;m not sure if this solve your problem but it can help you.&lt;br /&gt;Velocity in JournalArticle (Web Content) limit some variables to avoid develop complex tasks in template. &lt;br /&gt;If you want to enable variables disabled by default, you would modify portal-ext.properties.&lt;br /&gt;&lt;br /&gt;http://www.liferay.com/es/community/wiki/-/wiki/Main/Portal+Properties+6.0.5&lt;br /&gt;&lt;br /&gt;    #&lt;br /&gt;    # Input a comma delimited list of variables which are restricted from the&lt;br /&gt;    # context in Velocity based Journal templates.&lt;br /&gt;    #&lt;br /&gt;    journal.template.velocity.restricted.variables=serviceLocator</summary>
    <dc:creator>Rubén García Tamayo</dc:creator>
    <dc:date>2011-11-14T11:49:50Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11452329" />
    <author>
      <name>Maximilian Butterer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11452329</id>
    <updated>2011-11-14T09:43:11Z</updated>
    <published>2011-11-14T09:43:11Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;thanks for your reply, it helped me a lot. &lt;br&gt;But a problem remained: your code&lt;br&gt;&lt;pre&gt;&lt;code&gt;#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($userId = $getterUtil.getLong($request.get("attributes").get("USER_ID")))
#set ($user = $userLocalService.getUserById($userId))
$user.fullName&lt;/code&gt;&lt;/pre&gt; doesn't work for me. I don't get any data.&lt;br&gt;Do I have to enable Velocity in any other 'properties' file? Maybe it's too easy but actually I only set &lt;pre&gt;&lt;code&gt;velocity.engine.resource.manager.cache.enabled=true&lt;/code&gt;&lt;/pre&gt; in developer-properties.&lt;br&gt;Cheers&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Maximilian Butterer</dc:creator>
    <dc:date>2011-11-14T09:43:11Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11440647" />
    <author>
      <name>Deb Troxel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11440647</id>
    <updated>2011-11-11T22:31:20Z</updated>
    <published>2011-11-11T22:31:20Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div class="quote-title"&gt;ma bu:&lt;/div&gt;&lt;blockquote&gt;Hi there,&lt;br&gt;First of all: Is there anywhere a list of variables and functions which I can use here? &lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;&lt;br&gt;Although this page is not current, you may find some useful information here  &lt;a href="http://www.liferay.com/community/wiki/-/wiki/Main/Journal+Template+%28Velocity%29"&gt;http://www.liferay.com/community/wiki/-/wiki/Main/Journal+Template+%28Velocity%29&lt;/a&gt;&lt;br&gt;Instead of JournalVmUtil as mentioned on that page, refer to doTransform() in com.liferay.portlet.journal.util.VelocityTemplateParser.java&lt;br&gt;as well as insertHelperUtilities() in com.liferay.portal.velocity.VelocityVariables.java&lt;br&gt;&lt;br&gt;If you use the request object or parameters in a template, make sure that you uncheck the "Cacheable' option.&lt;br&gt;&lt;br&gt;Read through Ray Augé's old blogs for samples of what can be achieved using Web Content structures and templates, as well as accessing services.&lt;br&gt;&lt;a href="http://www.liferay.com/web/raymond.auge/blog"&gt;www.liferay.com/web/raymond.auge/blog&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;div class="quote-title"&gt;ma bu:&lt;/div&gt;&lt;blockquote&gt;&lt;br&gt;Till now I managed to get the UserID with &lt;pre&gt;&lt;code&gt;$request.get("attributes").get("USER_ID")&lt;/code&gt;&lt;/pre&gt; but how can I get the real user name?&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;Try:&lt;br&gt;&lt;pre&gt;&lt;code&gt;#set ($userLocalService = $serviceLocator.findService("com.liferay.portal.service.UserLocalService"))
#set ($userId = $getterUtil.getLong($request.get("attributes").get("USER_ID")))
#set ($user = $userLocalService.getUserById($userId))
$user.fullName&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;&lt;div class="quote-title"&gt;ma bu:&lt;/div&gt;&lt;blockquote&gt;&lt;br&gt;Next what I don't really understand is the following:&lt;br&gt;With &lt;pre&gt;&lt;code&gt;$groupId = $request.get("attributes").get("VIRTUAL_HOST_LAYOUT_SET").get("groupId")&lt;/code&gt;&lt;/pre&gt; it is possible to get the GroupID although &lt;pre&gt;&lt;code&gt;$myClass = $request.get("attributes").get("VIRTUAL_HOST_LAYOUT_SET").getClass()&lt;/code&gt;&lt;/pre&gt; returns "java.lang.String"&lt;br&gt;&lt;br&gt;By trying to get a similar value with e.g. &lt;pre&gt;&lt;code&gt;$userId = $request.get("attributes").get("USER").get("userId")&lt;/code&gt;&lt;/pre&gt; the value isn't interpreted although  &lt;pre&gt;&lt;code&gt;$myClass = $request.get("attributes").get("USER").getClass()&lt;/code&gt;&lt;/pre&gt; returns again "java.lang.String"&lt;br&gt;&lt;br&gt;Why is it possible to access the first "String" like a HashMap, but not the second one?&lt;br&gt;&lt;/blockquote&gt;&lt;br&gt;Hmmm, are you completely sure that the code you posted is what you were using?  I do not get $request.get("attributes").get("VIRTUAL_HOST_LAYOUT_SET").get("groupId") to return a groupId.  AFAIK, all of the request "attributes" available in web content are String representations of the values stored in the request, not objects.&lt;br&gt;&lt;br&gt;You can obtain the groupID directly as $groupId&lt;br&gt;&lt;br&gt;Hope this helps.&lt;br&gt;- Deb&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Deb Troxel</dc:creator>
    <dc:date>2011-11-11T22:31:20Z</dc:date>
  </entry>
  <entry>
    <title>RE: Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11430620" />
    <author>
      <name>Maximilian Butterer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11430620</id>
    <updated>2011-11-11T06:57:05Z</updated>
    <published>2011-11-11T06:57:05Z</published>
    <summary type="html">push</summary>
    <dc:creator>Maximilian Butterer</dc:creator>
    <dc:date>2011-11-11T06:57:05Z</dc:date>
  </entry>
  <entry>
    <title>Velocity and WebContent (CMS)</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11404582" />
    <author>
      <name>Maximilian Butterer</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=11404582</id>
    <updated>2011-11-09T12:58:36Z</updated>
    <published>2011-11-09T12:58:36Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi there,&lt;br&gt;&lt;br&gt;a few days ago I stumpled upon "Structures and Templates" for WebContents. It's a very nice feature but I don't really understand all of it.&lt;br&gt;I managed to create a structure and a corresponding template. Now I'm trying to enhance the Velocity Script in the template.&lt;br&gt;First of all: Is there anywhere a list of variables and functions which I can use here? &lt;br&gt;I found some lists but all these variables are only availible in themes and not in web content.(e.g. $user / $user_first_name )&lt;br&gt;Till now I managed to get the UserID with &lt;pre&gt;&lt;code&gt;$request.get("attributes").get("USER_ID")&lt;/code&gt;&lt;/pre&gt; but how can I get the real user name?&lt;br&gt;&lt;br&gt;Next what I don't really understand is the following:&lt;br&gt;With &lt;pre&gt;&lt;code&gt;$groupId = $request.get("attributes").get("VIRTUAL_HOST_LAYOUT_SET").get("groupId")&lt;/code&gt;&lt;/pre&gt; it is possible to get the GroupID although &lt;pre&gt;&lt;code&gt;$myClass = $request.get("attributes").get("VIRTUAL_HOST_LAYOUT_SET").getClass()&lt;/code&gt;&lt;/pre&gt; returns "java.lang.String"&lt;br&gt;&lt;br&gt;By trying to get a similar value with e.g. &lt;pre&gt;&lt;code&gt;$userId = $request.get("attributes").get("USER").get("userId")&lt;/code&gt;&lt;/pre&gt; the value isn't interpreted although  &lt;pre&gt;&lt;code&gt;$myClass = $request.get("attributes").get("USER").getClass()&lt;/code&gt;&lt;/pre&gt; returns again "java.lang.String"&lt;br&gt;&lt;br&gt;Why is it possible to access the first "String" like a HashMap, but not the second one?&lt;br&gt;Who can help me out?&lt;br&gt;&lt;br&gt;Thanks in advance!&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Maximilian Butterer</dc:creator>
    <dc:date>2011-11-09T12:58:36Z</dc:date>
  </entry>
</feed>
