Displaying the date field in calendar form
This recipe will use a number of techniques to transform a standard text-based date field into an eye-catching calendar form.
Getting ready
We will be using the myzen theme created earlier in this book as the example theme in this recipe. It is also assumed that a node.tpl.php
file exists in myzen's templates
folder.
How to do it...
We are going to break down this operation into three stages. The first is the preprocess stage where we break the node's timestamp down into the required component parts and introduce them as variables in a preprocess()
function.
Navigate to the myzen theme folder at
sites/all/themes/myzen
.Open the file
template.php
in an editor.Locate the
myzen_preprocess_node()
function, or if unavailable, create one.Add the following code into the aforementioned preprocess function so that it effectively looks like the following:
function myzen_preprocess_node(&$vars) { $vars['calendar_month'] = format_date($vars['node']->created...