Skip to content

Instantly share code, notes, and snippets.

View jamesfalkner's full-sized avatar

James Falkner jamesfalkner

View GitHub Profile
#set ($portalBeanLocator = $portal.getClass().forName("com.liferay.portal.kernel.bean.PortalBeanLocatorUtil"))
#set ($teamLocalService = $portalBeanLocator.locate("com.liferay.portal.service.TeamLocalService.velocity"))
#set ($userLocalService = $portalBeanLocator.locate("com.liferay.portal.service.UserLocalService.velocity"))
#set ($userId = $getterUtil.getLong($request.theme-display.user-id))
#set ($user = $userLocalService.fetchUserById($userId))
## teams
<p>
<#-- dump.ftl
--
-- Generates tree representations of data model items.
--
-- Usage:
-- <#import "dump.ftl" as dumper>
--
-- <#assign foo = something.in["your"].data[0].model />
--
-- <@dumper.dump foo />
#!/bin/sh
SRCFILE="$1"
cd TEMPLATES
for i in *.vm ; do
NN=`echo $i|sed 's/\.vm//'`
echo "put $SRCFILE $NN" | /opt/local/bin/cadaver http://localhost:8080/webdav/wcm-apps/journal/Templates
done
#!/bin/sh
mkdir -p TEMPLATES
cd TEMPLATES
echo 'mget *' | /opt/local/bin/cadaver http://localhost:8080/webdav/guest/journal/Templates
for i in * ; do
[ `echo $i | egrep ^[0-9]+$` ] &&
mv $i $i.vm
done
## AJAXification with well-formed JSON result construction
## AJAXification with AUI and JSON parameters
#set ($pns = $request.portlet-namespace)
<body>
<link href="//code.google.com/apis/maps/documentation/javascript/examples/standard.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//maps.google.com/maps/api/js?sensor=false"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.0.2/build/rollups/md5.js"></script>
##
## Expando Browser/Editor via Liferay WCM
##
#set ($pns = $request.portlet-namespace)
#set ($scopeGroupId = $getterUtil.getLong(${request.theme-display.scope-group-id}))
#if ($request.lifecycle == "RENDER_PHASE")
<body onload="${pns}getClassNames();">
<article>
## example expando with json
#if ($request.lifecycle == "RENDER_PHASE")
<p><em>Expando Demo 2: Creating and Reading Expando Data from AJAXified WCM Portlet Resource</em></p>
<div id="dataTable"></div>
<body onload="getExpando()">
<script type="text/javascript">
function getExpando() {
<p><em>Expando Demo 1: Creating and Reading Expando Data</em></p>
## get the static field constant for Expando String type.
## In freemarker, this is much easier:
## <#assign DATE = staticUtil["java.util.Calendar"].DATE>
#set ($expandoConstants = $portal.getClass().forName("com.liferay.portlet.expando.model.ExpandoColumnConstants"))
#set ($expandoConstantsInstance = $expandoConstants.newInstance())
#set ($stringType = $expandoConstants.getField("STRING").get($expandoConstantsInstance))
## create table
## AJAXification with well-formed JSON result construction and parameter passing
## Calling a Liferay JSON Web Service
#set ($pns = $request.portlet-namespace)
<body onload="${pns}doit()">
<p><em>Demo 7: Using Liferay JavaScript APIs</em></p>
<img src="http://www.liferay.com/osb-community-theme/images/custom/heading.png">
<div id="greeting"></div>
## AJAXification with well-formed JSON result construction and parameter passing
#set ($pns = $request.portlet-namespace)
#if ($request.lifecycle == "RENDER_PHASE")
<body onload="${pns}doit()">
<img
src="http://www.liferay.com/osb-community-theme/images/custom/heading.png"
style="float:right;width:20%">