I’ve been trying to figure out a way to limit the results in the listing and have come up with a semi-solution I wanted to share as it works, but is not really the best solution. Hoping someone smarter can run with the idea a bit and come up with a solution that might actually rely on event counts rather than day counts.
In calendar.inc.php:
1. I created a new parameter in /*Snippet Parameters*/
$dayplus = (isset($dayplus)) ? $dayplus : 10;
2. I set 2 new variables
$todaysDate = date("j");
$expDate = date($todaysDate + $dayplus);
3. I created a new .tpl file (called ’eachEventHide.tpl’) in the list template I am using and set the display of the li to "none"
<li style="display:none;"></li>
4. I duplicated the if($display == ’list’), creating a display type called ’finitelist’ and added and new tpl to handle the events outside the date range
$tpl['eachEventHide'] = file_get_contents($basePath. 'templates/' .$template. '/eachEventHide.tpl');
5. Then added an if statement that limits the list output to Today’s Event through X Days From Now (expDate)
if(($eventDate < $todaysDate) || ($eventDate > $expDate)) {$eachEvent = $tpl['eachEventHide'];}
6. Last, I added my new parameter and changed the display type in my Calendar snippet tag
[!Calendar? &emails=`[email protected]` &display=`finitelist` &dayplus=`7` &limit=`600` &template=`list-template-name`!]
Full "Finite List Code
/* Beginning of Finite List Output */
if ($display == 'finitelist')
{
$tpl['wrapper'] = file_get_contents($basePath. 'templates/' .$template. '/wrapper.tpl');
$tpl['eachEvent'] = file_get_contents($basePath. 'templates/' .$template. '/eachEvent.tpl');
$tpl['eachEventAlt'] = file_get_contents($basePath. 'templates/' .$template. '/eachEventAlt.tpl');
$tpl['eachEventHide'] = file_get_contents($basePath. 'templates/' .$template. '/eachEventHide.tpl');
if ($cal_dates)
{
$innerList = '';
for ($i = 0; $i < $limit; $i++)
{
if ($cal_dates[$i]['startMonth'] == $month )
{
$eventDate = $cal_dates[$i]['startDay'];
if($i % 2)
{
$eachEvent = $tpl['eachEvent'];
} else {
$eachEvent = $tpl['eachEventAlt'];
}
if(($eventDate < $todaysDate) || ($eventDate > $expDate))
{
$eachEvent = $tpl['eachEventHide'];
}
foreach ($cal_dates[$i] as $key => $value)
{
$eachEvent = str_replace('[+' . $key . '+]', $value, $eachEvent);
}
$innerList .= $eachEvent;
}
}
$output = str_replace('[+events+]', $innerList, $tpl['wrapper']);
}
}
/* End of List Output */
You can see it in action
http://www.goodecompany.com.php5-13.websitetestlink.com/index.html and
http://www.goodecompany.com.php5-13.websitetestlink.com/our-restaurants/the-armadillo-palace/the-armadillo-palace-event-calendar.html.
Hope this helps somebody.