Skip to content

Events List (Paging)

Events List (Paging)

<?php
if (!function_exists('cleanTime')) {
 function cleanTime($str) { 
    $newStr = explode(':00', $str);
    if (count($newStr)>1) $str = $newStr[0] . $newStr[1];
    return $str;
 }
}
?>

<template:if $LEAD_IN>
  ##$LEAD_IN##
</template:if>

<template:snippet name="render_paging_list" />
<?php
    $count = 0;
    $eventStruct = array();
?>
<template:list>
<template:item>
<?php
$event = array();
$start = time24To12($item['timeStart'], $doReturnString=true); 
$end = time24To12($item['timeEnd'], $doReturnString=true); 
$dateOut = dateOutput('M','d','Y',$item['dateStart'],$item['dateEnd'],$item['dateProvided']); 
$event['assets'] = $item['assets'];
$event['headline'] = $HEADLINE;
$event['dateOut'] = $dateOut;
$event['dateStart'] = $item['dateStart'];
$event['detail_href'] = $DETAIL_HREF;
$event['ordinal'] = $count+1;
$eventStruct[] = $event;
$count++;
?>
</template:item>
</template:list>

<template:if $templateConstants['isPublishing']><?php echo '<?php $eventStruct = ' . var_export($eventStruct, true) . '; ?>'; ?></template:if>
<template:code>
<?php
//**************************************************************************
//* MISCELLANEOUS
//**************************************************************************
 
// paging
	$paging 				= array();
	$paging['perPage'] 		= 20; // number of items per page
	$paging['totalRows'] 	= count($eventStruct);
	$paging['pageNum'] 		= gpc('page', 0);
	$paging['totalPages'] 	= ceil($paging['totalRows'] / $paging['perPage']) - 1;

// figure out which item we are going to start with and slice the array so we
// only execute the sort on the items we will be displaying.
	if ($paging['pageNum'] === 'all') {
	    $paging['viewAll']  = true;
		$paging['pageNum']  = 0;
		$paging['startRow'] = 0;
	} else {
		$paging['viewAll']  = false;
		$paging['startRow'] = $paging['pageNum'] * $paging['perPage'];
		$eventStruct = array_slice($eventStruct, ($paging['startRow'] ? $paging['startRow'] : 0), $paging['perPage']);
	}

renderPagingList($paging);
?>
<ul class="events list">
<?php

//**************************************************************************
//* DATA SETUP AND FORMATTING
//**************************************************************************
if (count($eventStruct)) {
	foreach ($eventStruct as $item) {
?>
<li><template:if $item['dateOut'] != 'TBD'><span class="date"><abbr class="dtstamp" title="##dateFormat('c', $item['dateStart'])##">##$item['dateOut']##</abbr></span></template:if>
<a href="##$item['detail_href']##">##$item['headline']##</a></li>
<?php
	}
}
?>
</ul>
<?php
  renderPagingList($paging);
?>

</template:code>

<template:if $LEAD_OUT>
  ##$LEAD_OUT##
</template:if>
Author
T. Bellefy / D. Butler
Date Written:
April 2008
Version:
1
Time:
1 hours
Department(s):
Production

Sites using this template:

Comments:

Requirements:

render_list_paging