0

I have a calendar of content type as a block. Currently clicking the date link opens the single day calendar view (from the Calendar template). Is it possible to display a view/list of events for the selected date on the same page? like this:

enter image description here

Thanks in advance!

1

One thing you can do is create a second block display view that's simply an html list of events (rather than a calendar display) and put that block on the same page as your current mini calendar.

The trick is that that event list can be set up to take a contextual filter that only displays it when you click on a day from your first calendar.

Here's how you can make it work

  1. Customize your calendar-datebox.tpl.php file (except make sure you name it such that you're only customizing it for your specific calendar block, rather than globally) and place in your custom theme's templates folder. It should have something like this, rather than the typical one line it comes with:

    // Notice how I'm placing the current day's selection into a URL variable called selected_day.  You may need to customize this a little to fit your needs.     
    <?php
      if ($selected) {
           $output = '<a href="/' . $_GET['q'] . '?selected_day=' . $date . '">' . $day . '</a>';      
    } else {
      $output = $day;     
    }  
    ?>
    <div class="<?php print $granularity ?> <?php print $class; ?>"> <?php print $output; ?> </div>
    
  2. Once you've done that, the links that are printed for your days that have events, will just add a parameter to your existing URL that is called 'selected_day', rather than replacing your calendar block.

  3. Now just create a new block, which is an html list that prints out the event's name, time and description, like you have in your screenshot. Place that block on the same page as your current calendar either via a context or your block's admin screen.

  4. Create a contextual filter for your new block listing, which should be the event's start date. Set the default value to be a php snippet, which just gets the url's 'selected_day' variable

return $_GET['selected_day'] ;

If both of your blocks are present on the page, the second one -- the listing -- shouldn't display anything until you click on an event date, at which point the url's variable will be created and the second block should appear. I just did a small test, and it works for me.

:-)

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.