ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Calendar Tag--hiding days out of month

February 21, 2012 1:29pm

Subscribe [2]
  • #1 / Feb 21, 2012 1:29pm

    futuraprime

    3 posts

    I’m trying to use the calendar tag (exp:channel:calendar) to show 3 months in a row. Consequently, I don’t want the month panes to show dates that aren’t in the month being shown. As best I can tell, the loop in mod.channel_calendar.php doesn’t even keep track of the month associated with a date, let alone provide a means of distinguishing these cells from the rest. Is there a way to do this?

  • #2 / Feb 21, 2012 1:48pm

    futuraprime

    3 posts

    Never mind—this is provided by the “blank” conditional, though this is not documented.

  • #3 / Feb 22, 2012 3:38pm

    Shane Eckert

    7174 posts

    Hello futuraprime,

    I am glad you were able to move forward on this.

    Would you mind pasting in your template code? I would like to see how you set this up in context with the rest of the template.

    Cheers,

  • #4 / Feb 22, 2012 3:52pm

    futuraprime

    3 posts

    Sure. I set up an embedded subtemplate, which is mostly copied off the documentation page:

    {exp:channel:calendar
     switch="calendarToday|calendarCell"
     channel="events"
     month="{embed:month}"
     year="{embed:year}"
     show_future_entries="yes"
     show_expired="yes"
    }
    
    <div class="calendar-pane">
     <table class="calendarBG" border="0" cellpadding="0" cellspacing="0" summary="My Calendar">
      <tr class="calendarHeader">
       <th colspan="7">
        {date format="%F %Y"}
       </th>
      </tr>
      <tr>
      {calendar_heading}
      <td class="calendarDayHeading">{lang:weekday_abrev}</td>
      {/calendar_heading}
      </tr>
      {calendar_rows}
       {row_start}<tr>{/row_start}
       {if entries}
        <td class='{switch}' align='center'>
         <a href="http://{day_path=events/date/index}">{day_number}</a>
        </td>
       {/if}
       {if not_entries}
        <td class='{switch}' align='center'>{day_number}</td>
       {/if}
       {if blank}
        <td class='calendarBlank'>{day_number}</td>
       {/if}
       {row_end}</tr>{/row_end}
      {/calendar_rows}
        </table>
    </div>
    {/exp:channel:calendar}

    Then I can just embed this template with the appropriate month and year, as many times as needed (fp_datemath is a tiny plugin I wrote to wrap PHP’s date and str_to_time functions):

    <div class="calendars">
     {embed="events/_calendar"
      month="{exp:fp_datemath format='m' modifier='1 month ago'}"
      year="{exp:fp_datemath format='Y' modifier='1 month ago'}"
     }
    
     {embed="events/_calendar"
      month="{exp:fp_datemath format='m' modifier='now'}"
      year="{exp:fp_datemath format='Y' modifier='now'}"
     }
    
     {embed="events/_calendar"
      month="{exp:fp_datemath format='m' modifier='1 month'}"
      year="{exp:fp_datemath format='Y' modifier='1 month'}"
     }
    </div>

    I’m hiding the off-month dates with CSS now.

  • #5 / Feb 24, 2012 3:04pm

    Dan Decker

    7338 posts

    Hi futuraprime,

    Very cool!

    Thanks for sharing your solution.

    Is there anything else we can assist you with?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases