When we are working with Liferay development and Liferay web content management system we will use many velocity variables.
Generally we will use velocity variables in theme and layout development. Apart from that we also use in the web content management system especially when we work with templates.
From Liferay 6.2 onwards we have Liferay Application Display Templates (ADT) to implement this we will use velocity templates and its variables related to Liferay.
The following article just shows the different velocity variables which are in Liferay
Variables Available to Layout a Template
Velocity Variable | Respective Java Class |
$processor | com.liferay.portal.layoutconfiguration.util.velocity.TemplateProcessor |
$request | javax.servlet.http.HttpServletRequest |
$themeDisplay | com.liferay.portal.theme.ThemeDisplay |
$company | com.liferay.portal.model.Company |
$user | com.liferay.portal.model.User |
$realUser | com.liferay.portal.model.User |
$layout | com.liferay.portal.model.Layout |
$layouts | java.util.List<com.liferay.portal.model.Layout> |
$plid | java.lang.Long |
$layoutTypePortlet | com.liferay.portal.model.LayoutTypePortlet |
$portletGroupId | java.lang.Long |
$locale | java.util.Locale |
$timeZone | java.util.TimeZone |
$theme | com.liferay.taglib.util.VelocityTaglib |
$colorScheme | com.liferay.portal.model.ColorScheme |
$portletDisplay | com.liferay.portal.theme.PortletDisplay |
$processor | com.liferay.portal.layoutconfiguration.util.velocity.TemplateProcessor |
$request | javax.servlet.http.HttpServletRequest |
$themeDisplay | com.liferay.portal.theme.ThemeDisplay |
$company | com.liferay.portal.model.Company |
$user | com.liferay.portal.model.User |
$realUser | com.liferay.portal.model.User |
$layout | com.liferay.portal.model.Layout |
$layouts | java.util.List<com.liferay.portal.model.Layout> |
Using velocity Objects:
Assume if we have method in java like user.getUserId()then in the velocity we can use like $user.getUserId()
Example to Display User Id:
#set ($user_id = $user.getUserId()) // Assignment in velocity
<span>($user_id </span>
Liferay 6 theme variables
When we work with theme development we may need to use many velocity variable all these variables are declared in initi.vm and this file will be included in all theme velocity templates so that we can use any of the variable which has declared in the init.vm
If we want to declare new variables so that we can use init_custom.vm file and it will be available in theme templates directory
The following is init.vm file
$theme_display $portlet_display $theme_timestamp $theme_settings $root_css_class $css_class $htmlUtil $languageUtil $getterUtil $portalUtil $localeUtil $liferay_toggle_controls $sessionClicks $request $locale $layout $page_group $liferay_dockbar_pinned $layoutTypePortlet $css_folder $images_folder $javascript_folder $templates_folder $full_css_path $full_templates_path $company_id $company $company_logo $company_logo_height $company_logo_width $company_url $user $user_id $is_default_user $user_middle_name $user_last_name $user_name $is_male $is_female $user_birthday $user_email_address $language $language_id $w3c_language_id $time_zone $user_greeting $user_comments $user_login_ip $user_last_login_ip $is_login_redirect_required $is_signed_in $group_id $show_add_content $add_content_text $add_content_url $layout_text $layout_url $show_control_panel $control_panel_text $control_panel_url $show_home $home_text $home_url $show_my_account $my_account_text $my_account_url $show_page_settings $page_settings_text $page_settings_url $show_sign_in $sign_in_text $sign_in_url $show_sign_out $sign_out_text $sign_out_url $show_toggle_controls $toggle_controls_text $toggle_controls_url $update_available_url $the_title $selectable $is_maximized $is_freeform $page_javascript_1 $page_javascript_2 $page_javascript_3 $layout $page = $layout $is_first_child $is_first_parent $the_title $is_portlet_page $all_portlets $column_1_portlets $column_2_portlets $column_3_portlets $column_4_portlets $column_5_portlets $maximized_portlet_id $typeSettingsProperties $page_javascript_1 $page_javascript_2 $page_javascript_3 $community_name $css_class $my_places_portlet_url $community_default_public_url $community_default_private_url $community_default_url $the_title $layouts $pages $nav_items $has_navigation $show_staging $staging_text $show_my_places $my_places_text $dir_include $bottom_include $bottom_ext_include $content_include $top_head_include $top_messages_include $date $current_time $the_year |
Velocity Variables Available in Web Content
The following are the velocity variable we can use in the Liferay web content manamgent when we create journal content/articles.
$reserved-article-id.data $reserved-article-version.data $reserved-article-title.data $reserved-article-create-date.data $reserved-article-modified-date.data $reserved-article-display-date.data $reserved-article-author-id $reserved-article-author-name $reserved-article-author-email-address $reserved-article-author-comments $reserved-article-author-organization $reserved-article-author-location $reserved-article-author-job-title |
Some of relevant java class related to velocity templates which give us some understating about velocity variables.
Author
0 comments:
Post a Comment