Skip to content

Instantly share code, notes, and snippets.

@farmerbradllc
Created April 13, 2012 23:49
Show Gist options
  • Select an option

  • Save farmerbradllc/2381044 to your computer and use it in GitHub Desktop.

Select an option

Save farmerbradllc/2381044 to your computer and use it in GitHub Desktop.
Recent Listings DDL template
## Get the reference of DDL Record Service via serviceLocator, which is automatically set in the context
#set($ddlRecordService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService'))
#set($ddlRecordSetService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordSetLocalService'))
#set ($localizationUtil = $portal.getClass().forName('com.liferay.portal.kernel.util.LocalizationUtil'))
## $reserved_record_set_id is also an object set in the context and it has the value of the list id configured for the portlet instance
#set ($recordSetId = $getterUtil.getInteger($reserved_record_set_id.data, 0))
## call to the retrieve all records of the list
#set ($records = $ddlRecordService.getRecords($recordSetId))
## call to the retrieve all record Sets
#set($recordSets = $ddlRecordSetService.getRecordSets($groupId))
$ddlRecordSetService.getDDLRecordSetsCount()
$companyId
#foreach ($recordSet in $recordSets)
## strips the localization from the recordSet.name variable
#set($recordName = $localizationUtil.getLocalization($recordSet.name, $request.theme-display.language-id))
#if ($recordName == "Photos")
#set($photo-list-id = $recordSet.recordSetId)
#end
#end
#set($list = #$ddlRecordSetService.search($companyId, $groupId, "MLS", 0, 0, 10, null))
#foreach ($i in $list)
$i.recordId
#end
<ul id="recent-listings" style="list-style: none;">
#foreach($record in $records)
#set ($fields = $record.getFields())
#set($id = $fields.get("id"))
#set($price = $fields.get("price"))
#set($bedroom = $getterUtil.getInteger($fields.get("bedroom").value, 0))
#set($bathroom = $getterUtil.getInteger($fields.get("bathroom").value, 0))
#set($size = $fields.get("home-size"))
#set($address= $fields.get("address"))
<li>MLS ID: $!id.value</li>
<li>Address: $!address.value</li>
<li>Bedroom: $bedroom</li>
<li>Bathroom: $bathroom</li>
<li>Price: $!price.value</li>
<li>Size: $!size.value sqft</li>
<li>Photos<br/>
#set ($photorecords = $ddlRecordService.getRecords($photo-list-id))
<ul>
#set($photo-count = 1)
#foreach($photorecord in $photorecords)
#set ($photofields = $photorecord.getFields())
#set ($photoid = $photofields.get("id"))
#if ($photoid.value == $id.value)
#set($order = "")
#if($photo-count == 1)
#set($order = $order + "first ")
#end
#if($order != "")
<li class="$order">
#else
<li>
#end
#set ($photoimage = $photofields.get("image"))
#set ($photofileName = $photoimage.getName())
#set ($photorecordId = $photorecord.recordId)
#if ($photoimage.value != "")
<img src='/documents/ddl/${photorecordId}/${photofileName}'/><br/>
#end
#set($photo-count = $photo-count + 1)
#end
</li>
#end
</ul>
</li>
#end
</ul>
## Get the reference of DDL Record Service via serviceLocator, which is automatically set in the context
#set ($ddlRecordService = $serviceLocator.findService('com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService'))
## $reserved_record_set_id is also an object set in the context and it has the value of the list id configured for the portlet instance
#set ($recordSetId = $getterUtil.getInteger($reserved_record_set_id.data, 0))
## call to the retrieve all records of the list
#set ($records = $ddlRecordService.getRecords($recordSetId))
<div>
<ul style="display: inline-block;">
#foreach($record in $records)
## each record has a collection of fields (name and avatar in our case)
#set ($fields = $record.getFields())
#set ($id = $fields.get("id"))
#set ($price = $fields.get("price"))
#set ($size = $fields.get("home-size"))
#set ($image = $fields.get("image"))
#set ($fileName = $image.getName())
#set ($recordId = $record.recordId)
<li style="display: block; float: left;"><img height="100" src='/documents/ddl/${recordId}/${fileName}' width="100" /> <br/>MLS ID: $id.value</li>
#end
</ul>
</div>
# Input a comma delimited list of variables which are restricted from the
# context in FreeMarker based Journal templates.
#
journal.template.freemarker.restricted.variables=serviceLocator
#
# Input a comma delimited list of variables which are restricted from the
# context in Velocity based Journal templates.
#
journal.template.velocity.restricted.variables=serviceLocator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment