This article is a follow up to "Drupal 7 Field API - A simple example". This article is intended for programmers. We build a proof-of-concept module who's sole purpose is to demonstrate features of the Drupal 7 Field API.
Please note! Folks should always start their learning process by reviewing the official "Examples for Developers" on Drupal.org. I also recommend that programmers peruse Drupal's source code itself to find real-world examples that follow best practices.
Links to the full source code listings are located at the bottom of this article.
Figure 1
Our new module is called "my date". We add several new features: the ability to style the date display; better control over the default date values; use of the JQuery date picker widget to select dates.
In the screen shot (Figure 1) we see 2 different content types. I've configured a custom display for each of the 2 content types demonstrated in the Figure 1. "my date" allows you to customize the display through configuration dialogs detailed below.
I broke each of the date instances in to 4 HTML div elements: container, month, day, year.
In addition, each of the date parts (month, day, year) can be toggled on or off (displayed or not displayed). In the Figure 1 examples, I turned the display of the year off.
I also allow an HTML style attribute to be applied to each HTML element. Again, that is the container div, month, date, year.
The date can be aligned (float) either right or left.
You also have the option of choosing a back ground image.
I am not a graphics designer nor a themer. The idea was to show you how easy it is to set the configuration controls
.
Drupal 7 allows you to create a separate configuration for a teaser view versus a full view, etc.