views

24
Aug
2011
Grayside

Infinite Null: Sorting NULL to Last

Please, keep in mind this post was written for Drupal 6 and Views 2! D7/Views 3 sites might not take so kindly to it.

Recently I was looking at creating a new Todo Feature with a due date. I cracked open CCK’s manage fields UI and added a date field, careful to keep in mind that the default value should be no date, which just happens to translate as NULL. You see, for my Todo use case, not all Todos would have a deadline.

My next step was to create a View of all upcoming items. I wanted the next most urgent todo to float to the top of the list. Sadly, NULL counts as 0 in database land, so my carefully clicked Sort was preloading all my urgent todos with all the lowest priority tasks.

Seeing as this was a SQL problem, I googled the ‘net for viable query tweaks. I found a nice article illustrating exactly what I wanted: MySQL Sort Order with NULL. The grand secret? Sort first by whether the duedate is NULL to flip your empty values to the bottom of the result set.

Read on to see how I added this change to my View.

15
Sep
2010
Grayside

How to Override a Views Field Template from a Module

Some months ago I wanted the solution to overriding a Views Field template entirely from within a module. I spent hours trawling documentation and issues, and playing with a little trial and error. In the end, I came up with a solution:

08
Sep
2010
Grayside

Adding a Content Type to the Open Atrium Calendar Views

People often seem to wonder how they can get their new date-specified content types to show up on the Atrium Calendar. The following Views snippet makes it happen for a content type called “example_type” in module “custom”. Note that this code is specific to the Views as they were renamed for Kit-compatibility in Open Atrium 1.0-beta8.

15
Jun
2010
Grayside

Optional Spaces Integration for a View

If you want to make an exported [node-based] View smoothly integrate with Spaces, you can use the following code to modify the View structure with the “Content in current space” filter. This filter does nothing if the View is not itself in a Space, otherwise it restricts all results to content in the same space. Add any conditions you want to control whether the Spaces integration is applied.

12
Apr
2010
Grayside

Changing Node Group Audience

In OpenAtrium, it’s not easy to change the group affiliation of a node once it has been created. OA locks down the interface to set group audience specifically to make the interface easier to understand.

I have just posted a quick feature that demonstrates how to grant administrators the ability to shuffle nodes around between groups, it can be found in the issue queue at community.OA.

06
Mar
2010
Grayside

OpenAtrium Empty Views: Gimme That Button!

Do you like the large gray “Add Blog entry” button when you first visit your blog space, and have yet to create anything? Creating views with similar buttons (or adding more) is really easy!

The key is to create Empty text in your view using the Full HTML Input Format. Then, drop some HTML in like this to make use of Atrium’s built-in theming.

07
Dec
2009
Grayside

Public Facing Site through Secured Syndication

When you need to stack content access mechanisms together in Drupal, things can get pretty messy. When you add Organic Groups to the mix, it gets pretty wild. I’ve been faced more than once with the challenge of building a site that would be 90% internal, and 10% public. Unfortunately, than 10% of public content represents 50% of the site’s complexity, especially when configuring around the settings and functionality required for a nice Intranet.

Subscribe to RSS - views