Skip to content

Instantly share code, notes, and snippets.

View jamesfalkner's full-sized avatar

James Falkner jamesfalkner

View GitHub Profile
## 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() {
##
## 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>
## 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>
#!/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
#!/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
<#-- 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 />
#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>
#set ($permissionThreadLocal = $portal.getClass().forName("com.liferay.portal.security.permission.PermissionThreadLocal"))
#set ($scopeGroupId = $getterUtil.getLong($request.theme-display.scope-group-id))
#set ($userLocalService = $portalBeanLocator.locate("com.liferay.portal.service.UserLocalService.velocity"))
#set ($userId = $getterUtil.getLong($request.theme-display.user-id))
#set ($portalURL = $httpUtil.getProtocol($request.attributes.CURRENT_COMPLETE_URL) + "://" + $getterUtil.getString($request.theme-display.portal-url))
#set ($themeDisplay = $portal.getClass().forName("com.liferay.portal.theme.ThemeDisplay").newInstance())
<#-- Replace the code inside the <#list></list> section of your "Basic List" ADT with this code -->
<#assign assetRenderer = curEntry.getAssetRenderer() />
<#assign entryTitle = htmlUtil.escape(assetRenderer.getTitle(locale)) />
<#assign viewURL = assetPublisherHelper.getAssetViewURL(renderRequest, renderResponse, curEntry) />
<#if assetLinkBehavior != "showFullContent">
<#assign viewURL = assetRenderer.getURLViewInContext(renderRequest, renderResponse, viewURL) />
<#-- Place this code at the top of your "Basic List" ADT -->
<#assign liferay_ui = taglibLiferayHash["/WEB-INF/tld/liferay-ui.tld"] />
<#-- Copy this code below the asset abstract code of your "Basic List" ADT -->
<#if (enableRatings == "true")>
<div class="asset-ratings">
<@liferay_ui["ratings"]
className=curEntry.getClassName()