> For the complete documentation index, see [llms.txt](https://help.pixfizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup/example-calendar-templates.md).

# Example Calendar Templates

Ready-made template definitions and calendar transformation rule sets to copy, paste and adapt.

Ready-made template definitions and calendar transformation rule sets to copy, paste and adapt.

## Overview

Writing a calendar definition from a blank page is slow and easy to get wrong. Start from one of these instead. Each definition is a complete, working starting point: paste it into the template's **Definition** field, change the page sizes to your product, and lay out the design.

The transformation rule sets are JSON arrays. Paste them into the **Calendar Transformations** field on the design page in admin, and merge them into a single array if you use more than one.

## How to use them

1. Copy the definition that matches your product.
2. Open **Admin > Products > Templates**, open your template and paste it into the **Definition** field.
3. Change `width`, `height`, `bleed`, `unit` and `dpi` to your real print specification. The values below are placeholders.
4. Save, then lay out the design and bind the date cells. See [Build a 12-Month Wall Calendar](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup/build-a-12-month-wall-calendar.md).
5. Add any transformation rule sets you need, renaming the element names in the JSON to match the names you gave your own elements.

## What to change, and what to leave alone

Safe to change:

* Page dimensions, bleed, margin, unit, dpi
* The page `type` names, as long as the design uses the same names
* The number of months in the loop sequence, for a 6-month or 18-month product

Change with care:

* The internals of a month-grid sequence. The `defdate`, `dateshift` and `tag` lines work together; editing one line usually breaks the grid at the start or end of the month.
* `count="false"` on the cover sets. Removing it changes the page count the customer and the pricing formula see.

## Template definitions

### 12-month wall calendar, weeks starting Monday

The usual starting point. Cover, twelve image pages, twelve month grids, back cover.

```xml
<definition output="pdf" unit="mm" dpi="300" minimum-dpi="100">

  <dates name="calendar-month">
    <defdate weekday="MO" name="monday-of-first-week"/>
    <dateshift to="monday-of-first-week">
      <dategen freq="daily" count="42"/>
    </dateshift>
    <defdate day="-1" name="last-day-of-previous-month"/>
    <dateshift to="monday-of-first-week">
      <defdate day="+41" name="last-generated-date"/>
    </dateshift>
    <dateshift to="monday-of-first-week">
      <dategen freq="daily" until="last-day-of-previous-month" tag="out-of-range"/>
    </dateshift>
    <dateshift month="+1">
      <dategen freq="daily" until="last-generated-date" tag="out-of-range"/>
    </dateshift>
  </dates>

  <dates name="by-month">
    <dateshift day="1">
      <dategen freq="monthly" count="12"/>
    </dateshift>
  </dates>

  <set count="false">
    <page type="cover" bleed="3" width="297" height="210"/>
  </set>

  <set foreachdate="by-month">
    <page type="image" bleed="3" width="297" height="210"/>
    <page type="calendar-month" dates="calendar-month" bleed="3" width="297" height="210"/>
  </set>

  <set count="false">
    <page type="back-cover" bleed="3" width="297" height="210"/>
  </set>

</definition>
```

### 12-month wall calendar, weeks starting Sunday

Identical except that the month grid anchors to the Sunday before the 1st.

```xml
<dates name="calendar-month">
  <dateshift day="-6">
    <defdate weekday="SU" name="sunday-of-first-week"/>
  </dateshift>
  <dateshift to="sunday-of-first-week">
    <dategen freq="daily" count="42"/>
  </dateshift>
  <defdate day="-1" name="last-day-of-previous-month"/>
  <dateshift to="sunday-of-first-week">
    <defdate day="+41" name="last-generated-date"/>
  </dateshift>
  <dateshift to="sunday-of-first-week">
    <dategen freq="daily" until="last-day-of-previous-month" tag="out-of-range"/>
  </dateshift>
  <dateshift month="+1">
    <dategen freq="daily" until="last-generated-date" tag="out-of-range"/>
  </dateshift>
</dates>
```

Use the rest of the Monday definition unchanged.

### Mini previous and next month grids

Add these two sequences when the calendar page shows small grids for the surrounding months, and list all three on the page: `dates="calendar-month previous-calendar-month next-calendar-month"`.

```xml
<dates name="previous-calendar-month">
  <defdate name="end-of-pre-previous-month" month="-1" day="-1"/>
  <defdate name="beginning-of-current-month"/>
  <dateshift month="-1" day="-6">
    <dateshift weekday="SU">
      <defdate name="final-date" day="+37"/>
      <dategen freq="daily" until="final-date"/>
      <dategen freq="daily" until="end-of-pre-previous-month" tag="out-of-current-month"/>
      <dateshift to="beginning-of-current-month">
        <dategen freq="daily" until="final-date" tag="out-of-current-month"/>
      </dateshift>
    </dateshift>
  </dateshift>
</dates>

<dates name="next-calendar-month">
  <defdate name="end-of-current-month" month="+1" day="-1"/>
  <defdate name="beginning-of-next-next-month" month="+2"/>
  <dateshift month="+1" day="-6">
    <dateshift weekday="SU">
      <defdate name="final-date" day="+37"/>
      <dategen freq="daily" until="final-date"/>
      <dategen freq="daily" until="end-of-current-month" tag="out-of-current-month"/>
      <dateshift to="beginning-of-next-next-month">
        <dategen freq="daily" until="final-date" tag="out-of-current-month"/>
      </dateshift>
    </dateshift>
  </dateshift>
</dates>
```

### Year at a glance

A single page showing all twelve months. Each month grid is its own named sequence, and all twelve are passed to one page.

```xml
<definition unit="mm" dpi="300" output="pdf" minimum-dpi="100">

  <dates name="year-at-a-glance">
    <date/>
  </dates>

  <!-- the Monday or Sunday calendar-month sequence goes here -->

  <dates name="calendar-year-month1"><dateshift month="1" day="1"><datesfrom name="calendar-month"/></dateshift></dates>
  <dates name="calendar-year-month2"><dateshift month="2" day="1"><datesfrom name="calendar-month"/></dateshift></dates>
  <!-- repeat through calendar-year-month12 -->

  <layers>
    <layer name="background" visibility="on"/>
    <layer name="photo" visibility="on"/>
    <layer name="artwork" visibility="on"/>
  </layers>

  <set foreachdate="year-at-a-glance">
    <page type="product"
          dates="calendar-year-month1 calendar-year-month2 calendar-year-month3 calendar-year-month4 calendar-year-month5 calendar-year-month6 calendar-year-month7 calendar-year-month8 calendar-year-month9 calendar-year-month10 calendar-year-month11 calendar-year-month12"
          bleed="0" width="420" height="594"/>
  </set>

</definition>
```

### Weekly desk calendar

One spread per week. Test this one before selling it: the number of weeks that fall in a year varies.

```xml
<definition unit="mm" dpi="300" output="pdf" minimum-dpi="100">

  <dates name="calendar-week">
    <dateshift weekday="MO">
      <dategen freq="daily" count="7"/>
    </dateshift>
  </dates>

  <dates name="by-week">
    <dateshift weekday="MO">
      <dategen freq="weekly" count="53"/>
    </dateshift>
  </dates>

  <set count="false">
    <page type="cover" bleed="3" width="210" height="148"/>
  </set>

  <set foreachdate="by-week">
    <page type="week-left"  dates="calendar-week" bleed="3" width="210" height="148"/>
    <page type="week-right" dates="calendar-week" bleed="3" width="210" height="148"/>
  </set>

</definition>
```

### Page-a-day calendar

One page per day. 366 pages in a leap year, so check the page limit against the binding first.

```xml
<definition unit="mm" dpi="300" output="pdf" minimum-dpi="100" max="370">

  <dates name="calendar-day">
    <date/>
  </dates>

  <dates name="by-day">
    <defdate name="end-of-year" year="+1" month="1" day="1"/>
    <dategen freq="daily" until="end-of-year"/>
  </dates>

  <set foreachdate="by-day">
    <page type="day" dates="calendar-day" bleed="3" width="105" height="148"/>
  </set>

</definition>
```

## Transformation rule sets

### Grey the out-of-range days

```json
[
  { "selector": { "tag": "out-of-range" }, "action": "set-color", "value": "#b3b3b3" }
]
```

### Hide the out-of-range days

```json
[
  { "selector": { "tag": "out-of-range" }, "action": "delete" }
]
```

### Sundays and holidays in red

```json
[
  { "selector": { "weekday": "SU" }, "action": "set-color", "value": "#cc0000" },
  { "selector": { "calendar": "website:holidays" }, "action": "set-color", "value": "#cc0000" }
]
```

### Short upper-case month names

```json
[
  { "selector": { "name": "month", "month": 1  }, "action": "set-text", "value": "JAN" },
  { "selector": { "name": "month", "month": 2  }, "action": "set-text", "value": "FEB" },
  { "selector": { "name": "month", "month": 3  }, "action": "set-text", "value": "MAR" },
  { "selector": { "name": "month", "month": 4  }, "action": "set-text", "value": "APR" },
  { "selector": { "name": "month", "month": 5  }, "action": "set-text", "value": "MAY" },
  { "selector": { "name": "month", "month": 6  }, "action": "set-text", "value": "JUN" },
  { "selector": { "name": "month", "month": 7  }, "action": "set-text", "value": "JUL" },
  { "selector": { "name": "month", "month": 8  }, "action": "set-text", "value": "AUG" },
  { "selector": { "name": "month", "month": 9  }, "action": "set-text", "value": "SEP" },
  { "selector": { "name": "month", "month": 10 }, "action": "set-text", "value": "OCT" },
  { "selector": { "name": "month", "month": 11 }, "action": "set-text", "value": "NOV" },
  { "selector": { "name": "month", "month": 12 }, "action": "set-text", "value": "DEC" }
]
```

### A logo on December only

Eleven rules. The element is named `brand-logo` in the design.

```json
[
  { "selector": { "name": "brand-logo", "month": 1  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 2  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 3  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 4  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 5  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 6  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 7  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 8  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 9  }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 10 }, "action": "delete" },
  { "selector": { "name": "brand-logo", "month": 11 }, "action": "delete" }
]
```

### Alternating artwork on odd and even months

Both versions sit on the same page, named `art-odd` and `art-even`.

```json
[
  { "selector": { "name": "art-even", "month": 1  }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 2  }, "action": "delete" },
  { "selector": { "name": "art-even", "month": 3  }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 4  }, "action": "delete" },
  { "selector": { "name": "art-even", "month": 5  }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 6  }, "action": "delete" },
  { "selector": { "name": "art-even", "month": 7  }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 8  }, "action": "delete" },
  { "selector": { "name": "art-even", "month": 9  }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 10 }, "action": "delete" },
  { "selector": { "name": "art-even", "month": 11 }, "action": "delete" },
  { "selector": { "name": "art-odd",  "month": 12 }, "action": "delete" }
]
```

### A background per season

```json
[
  { "selector": { "name": "season-bg", "month": 12 }, "action": "set-image-src", "value": "winter.jpg" },
  { "selector": { "name": "season-bg", "month": 1  }, "action": "set-image-src", "value": "winter.jpg" },
  { "selector": { "name": "season-bg", "month": 2  }, "action": "set-image-src", "value": "winter.jpg" },
  { "selector": { "name": "season-bg", "month": 3  }, "action": "set-image-src", "value": "spring.jpg" },
  { "selector": { "name": "season-bg", "month": 4  }, "action": "set-image-src", "value": "spring.jpg" },
  { "selector": { "name": "season-bg", "month": 5  }, "action": "set-image-src", "value": "spring.jpg" },
  { "selector": { "name": "season-bg", "month": 6  }, "action": "set-image-src", "value": "summer.jpg" },
  { "selector": { "name": "season-bg", "month": 7  }, "action": "set-image-src", "value": "summer.jpg" },
  { "selector": { "name": "season-bg", "month": 8  }, "action": "set-image-src", "value": "summer.jpg" },
  { "selector": { "name": "season-bg", "month": 9  }, "action": "set-image-src", "value": "autumn.jpg" },
  { "selector": { "name": "season-bg", "month": 10 }, "action": "set-image-src", "value": "autumn.jpg" },
  { "selector": { "name": "season-bg", "month": 11 }, "action": "set-image-src", "value": "autumn.jpg" }
]
```

## Related

* [Calendar Setup](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup.md)
* [Build a 12-Month Wall Calendar](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup/build-a-12-month-wall-calendar.md)
* [Date Sequences Reference](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup/date-sequences-reference.md)
* [Calendar Transformations](https://help.pixfizz.com/products-and-design/how-to-create-templates/calendar-setup/calendar-transformations.md)
