New Drupal tricks
I’m working on a Drupal project right now where I’m doing a lot of with Views and CCK. Most of my project always seem to involve both of these modules and it seems like every time I work with them I discover that I’ve only really scratched the surface in terms of using them. Last week I delved into the realm of Menu Tabs. Menu Tabs allow you to have a single page with several tabs each one which is a different view. This is a REALLY cool trick because it means that you can take tabs and attach them to a given page or type of page. You can for example attach a tab with a given view to a user page. In the case of my project, I’m using this to list a users content in a tab on their user page rather than has a separate page that they go to or having to deal with the less than ideal Drupal content page. It also allows you to take Organic Group content like My Groups or My Unread items and make them tabs within a user’s page. Personally I can think of lots of ways to use this. One thing I’d like to do is use it so that I could attach a new tab with a view to certain types of nodes. I haven’t figured out how to do this yet but I have high hopes.
Another new piece of views I’ve been learning about is View Attachments. Like Menu tabs, View Attachments allow you to associate several views with a single page. But what attachments allow you to do is stack multiple views all within the same page in an non-tabbed fashion. The classic example of this is the Calendar Module, which although it is its own model, leverages Views heavily to make great calendars. In the past I’ve used the Events module to create list of events, but I’m trying CCK Date and Calendar for this project and so far its working out great. My biggest concern? How to get signups to work on Nodes with repeating dates. Since the signup is attached to the single node it seems like using the repeating functionality is a no go if you want to use signups.
Calendar is just one way in which you can use Attachments in Views. I’ve been reading a book from Packt Publishing called Drupal 6 Attachment Views that demonstrates a number of different ways to use Attachments within Views. I’ve learned alot from it, but ironically I’ve actually found its explanations of how to theme views of the most use. (Fuller review of the book later.
The last trick I discovered this week is that I could create custom date formats. I learned this working on my project building an Event Calendar. One thing that irks me is that out of the box the calendar showed the date and the time, which to me made no sense because I could see what the date was based on where on the Calendar the event was displaying. Unfortunately, to generate the calendar I need to send the full date/time through. What I could do though was repeat the Date/Time field and format it differently for display. To do this you have to create a custom date/time format. You can do this in Administration > Site Configuration > Date/Time > Formats. I created a format that had only the time and for another display I was working on, one that had only the year. Then I could use either of these formats within my Views. The results are a nicer UI.
All of this seems to reinforce for me just how powerful Drupal is and also how many little tips, tricks and techniques ones can constantly be learning. By the time I’ve finished my current project I’m sure I’ll have more to share.
Update 4/21/2010
I was asked in the comments how I use the data format in the View. Basically there are two steps:
1. Select the date field
2. Choose the format you want to use. There are several that are included by default but any new ones add you can also use
The default format is usually the full date but you can choose other formats.


Thanks for the article. I’m wondering how you stated in the view your newly formatted time. Please share. Thanks.
Hello! I’m a library grad student who has been hired by my department to build a CMS website. I choose Drupal because I needed the functionality of Views. The link to my website is the one I’m working on for this IFLA funded project.
So, my questions are do you have live public examples of your Drupal websites? I’d love to see one which is more library centric! Do you know of a good place to learn more about panels? I’d like to have a way to organize the front page of my website with either Panels or Views attachment, but I don’t know where to start. Or even how to deal with users and their logins. I don’t think I want the users to choose their own usernames since this is a professional website, so I’d rather have people go by “Nancy Greene” rather than “nlgreene52″. Do you think having real names is a good idea for a website that is geared towards librarian professionals?
Sorry for all the questions! I’m just so excited to see another librarian using Drupal!