views

Drupal: 'Views2 Returns Zero Results but SQL Is Fine' Problem

This has happened couple times, already, so I may as well blog about it. If you use Views in Drupal, you already know that it shows you the final SQL generated. Very useful feature, but there's a rare edge condition when the SQL returns results (if you run it from an SQL client), but Views shows zero elements. Extremely frustrating and confusing.

How can this happen?

The thing is, Views omits limit condition when displaying the SQL, so when you copy/paste your SQL in a client you are not running exactly the thing that Views displays.

Solution: check the pagination setting in the View settings. Most of the time the problem is an offset value indicated that is higher than number of elements in the result-set.

Using Node References on a Multilingual Website

CCK Node Reference is an excellent module that allows creation of complex relationships between content types in Drupal. Combine that with Views2 feature called Relationships and you have one of the most sophisticated information architecture design tools any CMS has ever seen. At least - if you stick to one language. When you are working on a multilingual website, though, things get complicated. In this blog post we will discuss how to properly configure node references on a multilingual Drupal website.

Printer-Friendly Calendar View

Calendar module is one of the most useful modules in Drupal. It allows to create and view different events in time. Equally important module is Printer-Friendly which allows to have Print link and formats page in a printer-friendly style.

Unfortunately, Printer-Friendly module only works with node pages and calendar views are Views module pages so printer-friendly does not work with them. Following is a quick tutorial (inspired by Chill35's suggestion) on how to create printer-friendly pages for Calendar. Actually, the trick can be used for any views page, with some modifications.

The essence of the trick is that when we need a printer-friendly version of a page, we add "printit" to the end of the URL and when it is in the URL modify CSS accordingly to strip-off header/footer/etc. In Calendar module's case (which is actually called "events") you need to edit event_link() method in event.modules file.

Syndicate content