Skip to content
Snippets Groups Projects
programs-listing.vtl 5.56 KiB
Newer Older
Brad's avatar
Brad committed
##----
## set todays date to show date ranges
##----
#set($today = $date.format('yMMdd',$date))

##----
## sets future date
##----
## Get a java Calendar
#set($x = $date.calendar)
## Add 1 year (hours=int code 1)
$x.add(1,1)
## format future date
#set($future = $date.format('yMMdd',$x))


## --------------------------------------------------
## SETTING THE DEFAULT NUMBER OF RESULTS ------------
## --------------------------------------------------
#if (!$UtilMethods.isSet($numberOfResults))
  #set($numberOfResults = 100)
#end

## --------------------------------------------------
## FILTER BY CATEGORIES -----------------------------
## --------------------------------------------------
#set($catsQuery = "")
#foreach ($catInode in $topic)
  #if ($velocityCount == 1)
    #set($catsQuery = "categories:$categories.getCategoryByInode($catInode).categoryVelocityVarName")
  #else
    #set($catsQuery = "$catsQuery categories:$categories.getCategoryByInode($catInode).categoryVelocityVarName")
  #end
#end
#if ($UtilMethods.isSet($catsQuery))
  #set($catsQuery = "+($catsQuery)")
#end

#set($ignoreQuery="")
#if($UtilMethods.isSet($URLMapContent.inode))

  #set($ignoreQuery="-inode:$URLMapContent.inode")
#end

## --------------------------------------------------
## FILTERS BY TAGS ----------------------------------
## --------------------------------------------------
#set($tagsQuery = "")
#if ($UtilMethods.isSet($tagsFilter))
  #foreach ($tag in $tagsFilter.split(','))
    #if ($velocityCount == 1)
      #set($tagsQuery = "+Programs.tags:$tag")
    #else
      #set($tagsQuery = "$tag +Programs.tags:$tag")
    #end
  #end
#end

## --------------------------------------------------
## SETTING PAGINATED RESULTS ------------------------
## --------------------------------------------------
#if($pagination.contains('true'))
  ## SETTING ITEMS PER PAGE
  #if ($UtilMethods.isSet($itemsPerPage))
    #set($itemsPerPage = $webapi.parseInt($itemsPerPage))
  #else
    #set($itemsPerPage = 5)
  #end

  ## GETTING PAGE NUMBER
  #if($UtilMethods.isSet($request.getParameter('page')))
    #set($page = $webapi.parseInt($request.getParameter('page')))
  #else
    #set($page = 1)
  #end
#end
#set($myHost = $webapi.resolveHostName($request.serverName))

## --------------------------------------------------
## SETTING THE SORT ORDER ---------------------------
## --------------------------------------------------
## defaults to title if not set
#if(!$UtilMethods.isSet($sortBy))
    #set($sort = "modDate")
#end

#if($UtilMethods.isSet($sortBy))
	#if($sortBy.contains('tite'))
		#set($sort = "tite")
	#else
		#set($sort = "Programs.startDate")
	#end	
#end

#if($pagination.contains('true'))
  #set($programsListing = $dotcontent.pullPerPage("+contentType:Programs +(conhost:$host.identifier #if($systemHost.contains('true'))conhost:SYSTEM_HOST#end) #if($filterOutByDate.contains('true'))+Programs.endDate:[${today}* TO ${future}*]#end $!{catsQuery} $!{tagsQuery} ${ignoreQuery}",$!{page},$!{itemsPerPage},"$sort"))
#else
  #set($programsListing = $dotcontent.pull("+contentType:Programs +(conhost:$host.identifier #if($systemHost.contains('true'))conhost:SYSTEM_HOST#end)  #if($filterOutByDate.contains('true'))+Programs.endDate:[${today}* TO ${future}*]#end ",$math.toInteger($!{numberOfResults}),"$sort"))
#end

#if($UtilMethods.isSet($headline))
	#if(!$UtilMethods.isSet($headlineType))
		#set($headlineType = '1')
	#end
	<h$!{headlineType}>#if($UtilMethods.isSet($programsHomepageUrl))<a href="${programsHomepageUrl}">$!{headline}</a>#else$!{headline}#end</h$!{headlineType}>
#end

#if($programsListing.size() > 0)
	<ul class="programs-list">
	#foreach($program in $programsListing)
		<li class="program-item">
			#editContentlet($program.inode)
			#if($fieldsToDisplay.contains('programImage') && $UtilMethods.isSet($program.programImage.rawUri))
				<a href="/programs/$!{program.urlTitle}"><img class="program-image" src="/contentAsset/image/$!{program.identifier}/image/filter/Resize/resize_w/100" alt="$!{program.title}"></a>
			#end
			#if($fieldsToDisplay.contains('title') && $UtilMethods.isSet($program.urlTitle))
				<h3><a href="/programs/$program.urlTitle">$program.title</a></h3>
			#end
			#if($fieldsToDisplay.contains('startDate') && $UtilMethods.isSet($program.startDate))
				<p class="date">$date.format('E, MMMM dd, y', $program.startDate)#if($fieldsToDisplay.contains('endDate') && $UtilMethods.isSet($program.endDate)) &ndash; $date.format('E, MMMM, dd, y', $program.endDate)#end #if($fieldsToDisplay.contains('time') && $UtilMethods.isSet($program.time)) &ndash; <span class="time">$program.time</span>#end</p>
			#end
			#if($fieldsToDisplay.contains('location') && $UtilMethods.isSet($program.location))
				<p class="location">$program.location</p>
			#end
			#if($fieldsToDisplay.contains('summary') && $UtilMethods.isSet($program.summary))
				<p>$program.summary</p>
			#end
		</li>
	#end
	</ul>
	#if($UtilMethods.isSet($programsHomepageUrl))
		<p><a href="${programsHomepageUrl}">view all programs</a></p>
	#end
	#if($pagination.contains('true') && $programsListing.totalPages > 1)
      <ul class="pagination">
        #if($programsListing.previousPage)
          <li><a href="/programs/?page=$!{math.sub($page, 1)}">&laquo;</a></li>
        #end
        #foreach($i in [1..$programsListing.totalPages])
          <li #if($page == $velocityCount)class="active"#end><a href="/programs/?page=${velocityCount}">$velocityCount</a></li>
        #end
        #if($programsListing.nextPage)
          <li><a href="/programs/?page=$!{math.add($page, 1)}">&raquo;</a></li>
        #end
      </ul>
  #end
#else
	<p>There are no programs at this time.</p>
#end