Skip to content

Instantly share code, notes, and snippets.

@farmerbradllc
Last active December 12, 2015 10:09
Show Gist options
  • Save farmerbradllc/4756880 to your computer and use it in GitHub Desktop.
Save farmerbradllc/4756880 to your computer and use it in GitHub Desktop.
Get Web Content by Tag
##
## Getting Services
##
#set ($searchEngineUtil = $portal.getClass().forName('com.liferay.portal.kernel.search.SearchEngineUtil'))
#set ($booleanQueryFactory = $portal.getClass().forName('com.liferay.portal.kernel.search.BooleanQueryFactoryUtil'))
#set ($sortFactory = $portal.getClass().forName('com.liferay.portal.kernel.search.SortFactoryUtil'))
#set ($searchContext = $portal.getClass().forName('com.liferay.portal.kernel.search.SearchContext').newInstance())
#set ($journalContentUtil = $portal.getClass().forName('com.liferay.portlet.journalcontent.util.JournalContentUtil'))
#set ($localizationUtil = $portal.getClass().forName('com.liferay.portal.kernel.util.LocalizationUtil'))
#set ($journalStructureService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalStructureLocalService'))
#set ($journalTemplateService = $serviceLocator.findService('com.liferay.portlet.journal.service.JournalTemplateService'))
#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))
##
## Setting Variables
##
#set ($companyId = $getterUtil.getLong($request.theme-display.company-id))
#set ($ns = $request.portlet-namespace)
#set ($scopeGroupId = $getterUtil.getLong($request.theme-display.scope-group-id))
#set ($languageId = $request.theme-display.language-id)
#set ($V = $searchContext.setCompanyId($companyId))
#set ($V = $searchContext.setGroupIds([$scopeGroupId]))
##
## Define Search Query
##
#set ($fullQuery = $booleanQueryFactory.create($searchContext))
#set ($searchQuery = $booleanQueryFactory.create($searchContext))
#set ($V = $searchQuery.addRequiredTerm('portletId', '15'))
#set ($V = $searchQuery.addRequiredTerm('assetTagNames', "$tag.data"))
#set ($V = $fullQuery.add($searchQuery, 'MUST'))
#set ($hits = $searchEngineUtil.search($companyId, $fullQuery, $sortFactory.getDefaultSorts(), -1, -1))
<div id="NewsFlash">
<div id="NewsFlashTop"></div>
<div id="NewsFlashContent">
$title.data
<div class="NewsFlashItemsTop"></div>
<div id="NewsFlashItems">
#foreach ($doc in $hits.docs)
<div class="NewsFlashItem">
<div class="NewsFlashType">
#if ($doc.description)
${doc.description}:
#end
</div>
<div class="NewsFlashTitle">
<a href="${request.attributes.FRIENDLY_URL}/-/journal_content/56/${groupId}/${doc.articleId}">${doc.title}</a>
</div>
</div>
#end
</div>
<div class="NewsFlashItemsBottom"></div>
</div>
<div id="NewsFlashBottom">&nbsp;</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment