Thursday 14 September 2017

Liferay Default Theme Velocity Variables

List of velocity variables in theme template


Liferay Default Theme Velocity Variables tutorial will show light on the available velocity variables in Liferay theme. As you already know, Liferay already set parent variables in init.VM (/Liferay-home/tomcat/web apps/ROOT/HTML/themes/unstyled-theme/templates/init.vm).

Variables:

  • $theme_display
  • $portlet_display
  • $request
  • $css_folder       — -$theme_display.getPathThemeCss()
  • $images_folder —  $theme_display.getPathThemeImages()
  • $javascript_folder –$theme_display.getPathThemeJavaScript()
  • $templates_folder — $theme_display.getPathThemeTemplates()
  • $full_css_path
  • $company
  • $layout  –  Current layout
  • $user
  • $full_templates_path
  • $is_signed_in  — $theme_display.isSignedIn()
  • $current_time
  • $the_year
  • $permissionChecker.isOmniadmin() –> to check Super Admin
  • $dateUtil
  • $escapeTool
  • $propsUtil  -> To get Portal Ext Properties ($propsUtil.get(“propertye-key”))
  • $paramUtil
  • $getterUtil
  • $htmlUtil
  • $portalUtil
  • $portal
  • $prefsPropsUtil
  • $propsUtil
  • $portletURLFactory   ->    Here is sample code to create Portlet URL’s in Velocity templates.                     #set($test_plid = $portalUtil.getPlidFromPortletId($theme_display.getScopeGroupId(), false,                      “test_WAR_testportlet”))                                                                                                                   #set ($test_url = $portletURLFactory.create($request, “test_WAR_testportlet”,                                              $test_plid, “RENDER_PHASE”))                                                                                                                      $test_url.setWindowState(“normal”)                                                                                                        $test_url.setPortletMode(“view”)                                                                                                              $test_url.setParameter(“privateLayout”, “false”)                                                                                      $test_url.setParameter(“cmd”, “basicView”)
  • $stringUtil
  • $unicodeFormatter
  • $validator
  • $arrayUtil
  • $browserSniffer
  • $dateFormats
  • $dateTool
  • $dateUtil
  • $escapeTool
  • $expandoColumnLocalService
  • $expandoRowLocalService
  • $expandoTableLocalService
  • $expandoValueLocalService
  • $httpUtil
  • $imageToken
  • $iteratorTool
  • $languageUtil
  • $unicodeLanguageUtil
  • $localeUtil
  • $randomizer
  • $serviceLocator
  • $sessionClicks
  • $staticFieldGetter
  • $listTool
  • $mathTool
  • $sortTool
  • $numberTool                                                                                                                                                                                                                                                                                                                  Useful code snippets in Liferay theme Velocity templates:
  • Theme. Runtime is used to insert portlet at theme level
    • $theme.runtime(“emailnotification_WAR_kpiemailnotificationportlet_INSTANCE_adfckdkkek”)
  • to check Omni admin
    • #if ($is_signed_in && $permissionChecker.isOmniadmin())
      #dockbar()
      #end
  • To get the cotent based on locale:
    • $languageUtil.get($locale, $the_title, $page.getName($locale))

  • No comments:

    Post a Comment