Jump to content

FieldtypeDayMonth


Pete
 Share

Recommended Posts

This little module allows you to store a month and day value in a single field. I originally needed it to specify how long a service runs for on a website - the type of service that runs from the same day and month every year (so datepicker wouldn't be useful there).

It was more of a test to see how easy it is to build my own fieldtype - following ryan's map marker module and Soma's rangeslider module really helped and I have a few really good ideas for fieldtypes now :)

It's not a particularly useful module as the same can be achieved with individual fields in a fieldset (well, with Month names stored as pages - something I didn't want to do) but I expanded on it a bit and made it multilingual-friendly with month names etc.

On the admin side, you select a month and day from the two drop-downs, and on the front-end you can call them indovidually as numbers like this:

echo $fieldname->day;
echo $fieldname->month;

or formatted as per the option under the field's "details" tab like this:

echo $fieldname->formatted;

which will display something like "April 20" which is USA-friendly (I think), but you can change the default formatting as per details here: http://php.net/strftime

All in all, but of a niche field that probably won't get used much as you could even achieve the same with a text field and type it in, but I wanted the actual numerical day and month to perform date range calculations against a calendar so it needed to be more foolproof.

FieldtypeDayMonth.zip

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...