Skip to content

Instantly share code, notes, and snippets.

View elindoorn's full-sized avatar

Ernst Lindoorn elindoorn

  • Finalist
  • Netherlands
View GitHub Profile
@elindoorn
elindoorn / web-content-display-in-theme.vm
Last active March 14, 2016 16:19
Web content display in theme in Liferay 6.2, gets article by title so we don't need to hardcode id's
#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))
#set ($headerArticleId = $journalArticleLocalService.getArticleByUrlTitle($group_id, "header").getArticleId())
#set ($headerContent = $journalContentUtil.getContent($group_id, $headerArticleId, "view", $locale.toString(), $themeDisplay))
$headerContent
@elindoorn
elindoorn / format-date.vm
Last active November 30, 2015 15:55
Format date in template (Liferay 6.2)
#set ($date = $dateTool.toDate("EEE, dd MMM yyyy hh:mm:ss Z", $reserved-article-modified-date.getData(), $localeUtil.getDefault()))
#set ($timeZone = $timeZoneUtil.getTimeZone($user.getTimeZoneId()))
#set ($dateTimeFormat = "EEEE d MMMM yyyy")
#set ($modifiedDate = $dateTool.format($dateTimeFormat, $date, $locale, $timeZone))
$modifiedDate
Alternative to get a language specific format:
#set ($dateTimeFormat = $languageUtil.get($locale, "project-date-format"))
Then define project-data-format in the language files
@elindoorn
elindoorn / search-configuration-in-theme.vm
Last active May 6, 2019 05:02
Change search portlet configuration in theme (Liferay 6.2)
## Replace $theme.search() with our own form, note that you can still use it, just make sure the search.vm
## is loaded before you add the search portlet. We removed it to simplify changing styles on the search bar
## in the theme.
<form action="" method="get" name="search">
<input name="p_p_id" type="hidden" value="3">
<input name="p_p_lifecycle" type="hidden" value="0">
<input name="p_p_state" type="hidden" value="maximized">
<input name="p_p_mode" type="hidden" value="view">
<input name="_3_struts_action" type="hidden" value="/search/search">
<input name="_3_keywords" size="30" title="Search" type="text" value="" placeholder="Search here...">
@elindoorn
elindoorn / reserved-web-content-variables.txt
Last active October 13, 2023 14:26
Reserved web content variables
reserved-article-asset-tag-names
reserved-article-author-comments
reserved-article-author-email-address
reserved-article-author-id
reserved-article-author-job-title
reserved-article-author-location
reserved-article-author-name
reserved-article-author-organization
reserved-article-create-date
reserved-article-description