<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Passing Curiosity: Posts tagged date</title>
    <link href="https://passingcuriosity.com/tags/date/date.xml" rel="self" />
    <link href="https://passingcuriosity.com" />
    <id>https://passingcuriosity.com/tags/date/date.xml</id>
    <author>
        <name>Thomas Sutton</name>
        
        <email>me@thomas-sutton.id.au</email>
        
    </author>
    <updated>2010-07-05T00:00:00Z</updated>
    <entry>
    <title>Using Litecal</title>
    <link href="https://passingcuriosity.com/2010/using-litecal/" />
    <id>https://passingcuriosity.com/2010/using-litecal/</id>
    <published>2010-07-05T00:00:00Z</published>
    <updated>2010-07-05T00:00:00Z</updated>
    <summary type="html"><![CDATA[<p><a href="http://code.developmentseed.org/litecal/node/285">litecal</a> is a small Drupal module written by <a href="http://www.developmentseed.org/">Development Seed</a>
to provide a lightweight calendar display for Drupal sites. Like the larger
and more powerful <a href="http://drupal.org/project/calendar">calendar</a> module, <code>litecal</code> is depends on both
the Views and Date API modules. Unlike <code>calendar</code>, <code>litecal</code> is relatively
small and quite easy to understand. The rest of this post will guide you
through installing and using <code>litecal</code> to create a calendar of events on
your Drupal site.</p>
<hr />
<h3 id="installing-litecal">Installing <code>litecal</code></h3>
<p>As mentioned above, <code>litecal</code> has a number of dependancies. You’ll need to
download and install the following modules:</p>
<ol type="1">
<li><a href="http://code.developmentseed.org/litecal/node/285">Litecal</a> itself.</li>
<li><a href="http://drupal.org/project/cck">Content</a> and Text - to store the event data.</li>
<li><a href="http://drupal.org/project/date">Date</a> and Date API - to process and store date data.</li>
<li><a href="http://drupal.org/project/views">Views</a> - to display the calendar.</li>
</ol>
<p>Once you’ve installed the modules you may need to configure them (you’ll need
to have set the site timezone, if nothing else), and then move on to the next
step.</p>
<h3 id="creating-the-node-type">Creating the node type</h3>
<p>Before you can display events on a calendar, you’ll need somewhere to store
them so the first step is creating a new content type.</p>
<figure>
<img src="/files/2010/07/litecal-event-type.jpg" alt="Create an event content type" />
<figcaption aria-hidden="true">Create an event content type</figcaption>
</figure>
<p>Next you’ll need to add a few fields to it. You can store the event name and
description in the <code>title</code> and <code>body</code> fields, but you’ll need to add a new
text field for the location and a new date field for the date. Make sure that:</p>
<ul>
<li>The date field is required (you can’t have an event with no date).</li>
<li>The “to date” is optional.</li>
<li>At least year, month and day are selected under granularity.</li>
</ul>
<p>When you’re done you should have something like the following:</p>
<figure>
<img src="/files/2010/07/litecal-type-fields.jpg" alt="Manage fields on calendar event" />
<figcaption aria-hidden="true">Manage fields on calendar event</figcaption>
</figure>
<p>Now that you’ve got a <em>Calendar Event</em> node type, create a few dummy nodes so
that there’s something to display on the calendar. Four or five should do it,
but make sure that a few are <em>this month</em> and one or two in past or future
months, or your calendar will be a bit empty!</p>
<figure>
<img src="/files/2010/07/litecal-create-nodes.jpg" alt="Create some Calendar Event nodes" />
<figcaption aria-hidden="true">Create some Calendar Event nodes</figcaption>
</figure>
<h3 id="creating-the-view">Creating the view</h3>
<p>Now you need to create a view to display the calendar events in a calendar.
Create a new view for nodes and add the following:</p>
<ol type="1">
<li><p>A filter <code>Node: Type = Calendar Event</code>.</p></li>
<li><p>A <code>Date: Date (node)</code> argument (select the <em>Current date</em> as default
argument, <em>Month</em> granularity, both <em>From</em> and <em>To</em> dates, and <em>OR</em>
method).</p></li>
<li><p>A <code>Content: Date - From date</code> field from your content type, a <code>Content:     Location</code> field, and a <code>Node: Title</code> field.</p></li>
</ol>
<p>Your view should look something like this:</p>
<figure>
<img src="/files/2010/07/litecal-create-view.jpg" alt="Create a view" />
<figcaption aria-hidden="true">Create a view</figcaption>
</figure>
<p>Now add a new <code>Page</code> display to the view, set its <em>Name</em> to <code>Calendar</code>, the
<em>Path</em> to <code>calendar</code>, and override the <em>Style</em> and set it to <code>Litecal</code> (leave
the style options as the default values).</p>
<figure>
<img src="/files/2010/07/litecal-calendar-display.jpg" alt="Add a calendar display" />
<figcaption aria-hidden="true">Add a calendar display</figcaption>
</figure>
<p>Save the view, then select the correct display under <em>Live Preview</em> and you
should see the dummy nodes you created earlier on a calendar of the current
month. If not, then you’ve missed a step above (perhaps the default value or
granularity for the argument?).</p>
<figure>
<img src="/files/2010/07/litecal-preview.jpg" alt="The calendar in live preview" />
<figcaption aria-hidden="true">The calendar in live preview</figcaption>
</figure>
<p>You should also be able to visit <code>/calendar</code> and see the same calendar as a
page:</p>
<figure>
<img src="/files/2010/07/litecal-calendar-page.jpg" alt="The calendar in a page" />
<figcaption aria-hidden="true">The calendar in a page</figcaption>
</figure>
<h3 id="conclusion">Conclusion</h3>
<p>You’ve seen how easy it is to get started with the <code>litecal</code> module. In the
next post, I’m going to introduce a few more sophisticated ways you can use
<code>litecal</code> to build more complete user interface.</p>]]></summary>
</entry>

</feed>
