Anyone know how to "unlink" the {next_path} or {previous_path} for {exp:channel:calendar} if there aren't any entries for the next or previous month when building the mini-calendar?

  • I see that this was tagged with Solspace Calendar, but it refers to the first-party tag. Is this correct? If so, I think the question should be revised to include this. And if not, the Solspace tag should be removed. Commented Dec 15, 2012 at 15:34
  • Is this question about the Solspace Calendar Module or the native EE calendar option? Please clarify or we will need to remove the question.
    – Anna_MediaGirl
    Commented Dec 16, 2012 at 6:53
  • I've removed the Solspace tag since it's clear from the question body they are using the native EE calendar. Commented Dec 24, 2012 at 18:40

1 Answer 1


I had an answer for this on the EE Wiki, but can't see that it exists anymore -- even the Wayback Machine can't find it. So, here is some EE template source which will show you how to do it, which I've used for years on a site - I believe it will fit EE1 as well as EE2.

The principle is to use database queries via the EE Query module - be sure to have it enabled. If I were doing this today, I would probably make an add-on to allow the code to be simpler to look at.

It works well, however, just to embed the queries as we're writing out the calendar. We look for whether there are later (or earlier) entries. If there are, we write out the link, visibly showing appropriate corner brackets which make the buttons. If there aren't, we write nothing, leaving a blank cell, which looks right.


-- this solution is for the first-party (EE tag) calendar. It seems to me that's what's referenced in the question, and you should remove the solspace-calendar tag if that's so, per Anna's request. If it is for Solspace Calendar, you should then say so, and maybe the queries here will also be useful, since I imagine you could play a similar trick.

-- the queries here are on exp_channel_titles, which fits EE2.x. That will be exp_weblog_titles if you are on EE1. If you used a database prefix, you'll have to include that too - the queries may only reference real table names in the database. There are ways to get that, but they seem not worth the complication for this case.

-- further on the query, note that I'm hard-coding channel_id = '6'. You can look up the channel_id number for the channel you want by using the EE control panel Tool>SQL Manager>Manage Database Tables, and clicking Browser for the table exp_channels.

-- there isn't much of a measurable performance hit using this method, among all the other queries which typically build a web page. If you want things to go really fast on a shared hosting, you can look into CE Cache, which is simple excellent.

-- the calendar tag used this way is one of the cases where you actually do want to have dynamic='yes', so that it follows the main channel entry you are showing.

-- if you're actually using some other kind of buttons, it's likely the queries should be used to set CSS labels to make them normally formatted or invisible, to achieve the effect you've asked for.

-- yes, it's a table -- that's the old EE way. Perhaps one place where tables actually make sense, since a calendar is one.

Good fortune, and nice holidays to all involved.

<h2 class="sidetitle">History</h2>
<br />
<div id="calendar"> 
 {exp:channel:calendar switch="calendarToday|calendarCell" channel="{my_channel}" dynamic="yes" show_pages="no" }
  <table class="calendarBG" border="0" cellpadding="5" cellspacing="1" summary="My Calendar">
      <th class="calendarHeader"><div class="calendarMonthLinks"> 
        {exp:query sql="SELECT year, month FROM exp_channel_titles where status = 'open' and channel_id = '6' and ((year = {date format="%Y"} and month < {date format="%n"}) or year < {date format="%Y"}) order by year desc, month desc limit 1;" } <a href="{path={my_template_group}/articles_all/{year}/{month}}">&lt;&lt;</a> {/exp:query}
      <th class="calendarHeader" colspan="5">{date format="%F %Y"}</th>
      <th class="calendarHeader"><div class="calendarMonthLinks"> 
        {exp:query sql="SELECT year, month FROM exp_channel_titles where status = 'open' and channel_id = '6' and ((year = {date format="%Y"} and month > {date format="%n"}) or year > {date format="%Y"}) order by year asc, month asc limit 1;" } <a href="{path={my_template_group}/articles_all/{year}/{month}}">&gt;&gt;</a> {/exp:query}
    <tr> {calendar_heading}
      <td class="calendarDayHeading">{lang:weekday_abrev}</td>
      {/calendar_heading} </tr>
    {calendar_rows }
      {if entries}
      <td class='{switch}' align='center'><a href="{day_path={my_template_group}/articles_all}">{day_number}</a></td>
      {if not_entries}
      <td class='{switch}' align='center'>{day_number}</td>
      {if blank}
      <td class='calendarBlank'>&nbsp;</td>
  • 1
    Awesome, thanks for sharing your solution here! Commented Dec 24, 2012 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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