Calendar block questions

Permalink
Hey,

I've bought the calendar block for my client's site.

I like using the different views,

but I don't like the agenda view as I don't like the set box height and the scroll bar on it if there are lots of events.

So i've used the list view but my only problems are, I liked having a link to the events indivual page and I want to limit the events just in case there are loads that end up trailing off the page.

So in summary how do I set up the list view so that each event is linked to its page and how to do I limit the number of events listed?

Thanks so much in advance

 
ryan replied on at Permalink Reply
ryan
Here's some code that will spit out a list of events strait into the page.

Create the file and directories:

[your site's root]/blocks/calendar/templates/linked_list.php

Concrete will pick that up as a custom template for the calendar block.

Add this code to the linked_list.php file:
<table class="ccm-calendar-all" cellspacing="0" cellpadding="0" border="0">
   <tr>
      <th width="100%">Event</th>
      <th>Date/Time</th>
   </tr>
   <?
   foreach($eventObjList as $ce) { ?>
   <tr>
      <td class="ccm-calendar-all-name"><strong><a href="<?=View::url($ce->getCollectionPath());?>"><?=$ce->getCollectionName()?></a></strong></td>
      <td class="ccm-calendar-all-date-time"><?=$ce->getDateString();?></td>
   </tr>
   <? 
   if ($ce->getCollectionDescription() != '') { ?>
   <tr>
      <td colspan="2" class="ccm-calendar-all-description"><?=$ce->getCollectionDescription()?></td>


The $eventObjList variable is an array of calendar events (they extend pages & collections) and you can loop through that & display how you'd like.

To display this template, click on an existing calendar block and then select "Choose Custom Template" and from the drop-down your template will be listed.
BeKindRewind replied on at Permalink Reply
BeKindRewind
Hi Ryan.

What would I change in this code if I just wanted to display the next 3 events?
ryan replied on at Permalink Reply
ryan
You could just stop the loop after 3 lines:

<table class="ccm-calendar-all" cellspacing="0" cellpadding="0" border="0">
   <tr>
      <th width="100%">Event</th>
      <th>Date/Time</th>
   </tr>
   <?
   $i = 0;
   foreach($eventObjList as $ce) { 
      $i++;
      ?>
   <tr>
      <td class="ccm-calendar-all-name"><strong><a href="<?=View::url($ce->getCollectionPath());?>"><?=$ce->getCollectionName()?></a></strong></td>
      <td class="ccm-calendar-all-date-time"><?=$ce->getDateString();?></td>
   </tr>
   <?
BeKindRewind replied on at Permalink Reply
BeKindRewind
Thanks Ryan! You're a lifesaver.