I've created a custom content type called Library. I've already added fields for phone (text), fax (text), email (email), website (link) and address (text). I'd now like to add a field or fields for opening and closing hours. I guess that many other sites need to do a similar thing. I could go the easy route and choose a single text field and use it to include all the data, but that won't help me format the data and I'm hoping for a more elegant solution. I've had a look for a suitable module and can't find anything. It doesn't specifically need to be for opening/closing hours, but it needs to be a field data type with a label (e.g. Mon-Fri) and two values (e.g. 09.00, 18.00). Maybe a three-column HTML table with Open and Close as two of the table headings would be a better solution. The number of rows would in the HTML table vary depending on the complexity of opening hours.
On second thoughts, maybe I'm looking at this thing the wrong way - already thinking about presentation of the data and not collection.
Any better suggestions? How might I implement this? Your suggestions are warmly welcomed.
Comments
You need the CCK Module.
You need the CCK Module. Allows you to add custom fields to your content type.
You can then add custom fields eg. Mon-Fri, Sat, Sun or whatever.
http://drupal.org/handbook/modules/cck
Already using the CCK
Thanks Solaris, but I'm already using the CCK. It's more a question of what to do next. I'm not sure I'd want to add fields for each day, as, for example, some places may be open the same hours every day.
I guess it all depends on
I guess it all depends on what you need to do with that data. Does it need to be searchable? Sortable? If not, then a separate CCK text field with an HTML input format could display a table.
If you want something that's more 'pure' in terms of data, you're going to need a lot of fields to cover all possibilities (eg a library that closes on Wednesday afternoons). To be honest, I'm not sure what the point of that would be though.
One fairly extreme possibility does spring to mind -- the schedule module that's inside the station package. It's aimed at radio station schedules, so would need a lot of hacking to be made generic -- something the module maintainer and I have talked about. It would also be overkill, as it's designed to show different things (ie radio shows) on a single schedule, and you only want an 'open/closed' distinction. But there's code there that makes a pretty weekly schedule. But like I say, bit extreme.
OK.... CCK text field containing HTML table
Joachim,
Probably doesn't need to be searchable or sortable, just presented nicely. I think your first solution of a CCK text field containing an HTML table may be the best solution. I very much doubt it's worth my time hacking the station package, but thanks for mentioning it anyway.
You could use this module
You could use this module http://drupal.org/project/office_hours which is still in development but seems to be very stable.
Andrew
Re: Open/Closed Hours
Newbie here again and wondering how to implement a way of displaying whether things such as businesses are either open or closed at that exact moment (local site). As I'm not the most adept programmer I'm still at the beginning stage of trying to plan implementation of that functionality without getting into some sort of form that breaks down every single half-hour or so as a checkbox, then somehow utilize that in some equation with current time. (Yeah, this may be the last thing implemented, ugh)
Note that Google just implemented this feature and as local/geo info becomes more important this will become a standard feature/module/functionality request I'm guessing.