1

I am using Solspace Calendar for managing events. Unfortunately it is behaving weird with dates. When I want to list the events for a particular month, it starts from one or two dates of the previous month or ends at one or two dates from the next month.

I also checked the generated SQL query which clearly shows that the start date is from the previous month rather than first day of the current month.

Any idea what I'm doing wrong?

Here is my code:

{exp:calendar:cal date_range_start="year-month-01" date_range_end="year-month-last"} {display_each_year} {display_each_day} {events} <!-- List of entries here --> {/events} {/display_each_day} {/display_each_year} {/exp:calendar:cal}

1

This is a very common question (and likely already answered somewhere on this site in another thread):

You need to add the pad_short_weeks="n" parameter. A more detailed explanation of why can be found here: http://www.solspace.com/docs/calendar/calendar/#pad_short_weeks

From the Calendar documentation:

You'll likely need to have this parameter set to n in the event you're trying to display anything other than a typical calendar display. When set to n, weeks won't be "padded" to the nearest first day of the week and last day of the week, as Calendar does this by default for the sake of properly outputting and formatting a calendar.

So for example, using the date_range_start and date_range_end parameters, if your code looks like this:

date_range_start="2011-10-19" date_range_end="2011-10-21"  

With pad_short_weeks parameter NOT specified, Calendar will automatically display the entire week range (2011-10-16 - 2011-10-22). With pad_short_weeks="n", Calendar will just display the selected range (2011-10-19 - 2011-10-21).

The effect of pad_short_week="n" in Calendar

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.