Book Image

Drupal 5 Views Recipes

Book Image

Drupal 5 Views Recipes

Overview of this book

The Drupal View modules give you flexibility and freedom to customize the display of your web site's content. Although there are more than 100 views-enabled modules, few site administrators use Drupal Views to its full potential. This book will enable you to realize the fullest potential of this powerful resource by providing a wide variety of powerful recipes for creating and displaying a wide variety of views ñ essential classics you will use again and again to innovative display methods that will make your Drupal site stand out. Pick and choose the ones you would like to prepare for your web site. In this book you will find ninety-four recipes to create a wide selection of views. The list includes event listings, interactive calendars and timelines, maps, proximity search, podcasting, carousels, Views Fusion, and many more. You will also explore default views, views with CCK, and master a variety of ways to associate views with related content. Most people think of Views for site visitors. But Views can also be handy for site administrators. You will get to know the Views Bulk Operations module, along with Editable Fields, and Views Custom Fields. (You'll probably wonder why you never used them before!) If you want to take Views to the next level, the book contains a code-rich chapter on theming. However, you will find most of the recipes detailed by the author do not require any original coding at all. As you progress through the recipes, you will be immersed in such Drupal Views topics as fields, arguments, filters, exposed filters, sorting, style plug-ins, formatters, cloning and copying views. Because Drupal is a worldwide and ever adapting system, the author also includes great tips and resources for navigating the online Drupal community and expanding your knowledge of the recipes. Finally, there is an extensive Appendix, which includes listings of all default views, formatters and style plug-ins for Drupal 5, along with a categorized list of patches.
Table of Contents (22 chapters)
Drupal 5 Views Recipes
Credits
About the Author
Acknowledgement
About the Reviewer
Preface
Default Views in Drupal 5 Modules
Formatters
Style Plugins
Views Hooks for Coders
Modules Included in Recipe Ingredients
Additional Resources and Modules Mentioned in Recipes
Selected Noteworthy Patches to Views
Index

Preface

The Views module is a powerful and flexible tool for displaying content on a Drupal site. Views came on the Drupal scene in 2005. Developed primarily by an awesome coder named Earl Miles with much input from other Drupalers, it has revolutionized the Drupal website developer experience.

This book offers step-by-step Views recipes for use by Drupal administrators and themers. We will be cooking up an extensive smorgasbord. We'll create lists, tables, calendars, charts, maps, proximity searches, fused views, views bulk operations, and so on, while introducing a wide array of techniques and companion modules along the way. Most of the recipes require no programming, but some contain useful code snippets.

This book covers Views for Drupal 5.x. (Views 2 will be the primary subject of a separate book.)

Why release a book on a Drupal 5 module, when Drupal 6 has already been released? It's simple: Many web site developers use Drupal 5!

There are often good reasons for this. Web site developers like to be sure that required modules are in good working shape for the version of Drupal they select. If contributed modules required for the site are not yet ported to Drupal 6, it is a reasonable option to use Drupal 5. Also, if a developer is replicating most of the functionality of an existing Drupal 5 site, she may use Drupal 5. Many developers inherit web sites that are still based on Drupal 5 code. Additionally, developers are still releasing new Drupal 5 modules. Drupal 5 remains a rich and widely-used framework.

What this book covers

Chapter 1 introduces the Views module along with a Views Worksheet that will serve as a guide throughout the rest of the book. We create a basic view of Swim Groups.

In Chapter 2 we look at the six default views that come with the Views module. We learn which modules must be enabled for these views to appear and we get to know the feed selector and Term arguments. We end the chapter by creating a module with a default view of Swim Groups.

In Chapter 3 we incorporate CCK fields into views such as a Blog Roll, Guitar Chord Display, and a Block of Media Hits Associated with Press Releases. We share a variety of ways to associate views with related content, including Viewfield and Node Reference modules and building views from within a template.

In Chapter 4 we focus on date fields, calendars, upcoming events, and the timeline module. This chapter rounds out coverage of all of the Views User Interface fieldsets, including Exposed Filters.

In Chapter 5 we examine ten tools to ease the work of site administrators, including Views Bulk Operations, Editable Fields, ModuleInfo, and setting up cron.

In Chapter 6 we explore some rarely-covered but powerful modules, including: Views Fusion, Views Fast Search, Views Bonus Pack Export, and Google Maps Tools, We also create a YouTube Video Bar, detail the steps to install jQuery Update with a Lightbox2 Gallery, and examine how to use the Flag module for a variety of applications.

Chapter 7 is the theming chapter and a bit more code-rich than the others. We create a directory of available theme functions. We look closely at Views theme functions and override them when necessary. We cover some debugging strategies. We use CSS to create date badges and to control carousel formatting. Finally, we incorporate views into panels and tabs.

In Chapter 8 we focus on navigating the online Drupal community. We learn how to search the Views issue queue, and how to apply and create patches. We cover some Dos and don'ts for Drupal chat on IRC and create a few helpful browser buttons and search plug-ins to facilitate finding information online.

Appendix A lists all the default views available for Drupal 5

Appendix B gives a comprehensive list of Drupal 5 field formatters by module

Appendix C gives a Comprehensive list of Drupal 5 style plug-ins by module

Appendix D lists the Views 1 hooks

Appendix E lists the modules included in recipe ingredients

Appendix F lists the additional resources and modules

Appendix G lists the selected noteworthy patches to views, sorted by topic

What you need for this book

For most of the recipes, you'll need a Drupal 5 web site along with administrative access to the server and the site. (The Packt book, Building Powerful and Robust websites with Drupal 5 offers a comprehensive chapter on installation.) You may also want to use a printer or copy machine to prepare copies of the Views Worksheet.

Who this book is for

This book is primarily written for Drupal site builders, administrators, and themers who want to develop custom content displays using Views. It can be used by anyone who has developed or inherited a Drupal 5 site.

Some knowledge of HTML and CSS is required. PHP basics will be handy for some of the recipes.

How you read this book is your choice. Some readers will start from Recipe 1, working all the way through to the Appendix, to gain as much information as possible. Others will head straight for the most-needed recipe, turning back only to complete prerequisite steps. However you approach it, cook up a storm!

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "The last argument of that command was views.module."

A block of code will be set as follows:

if ($field['fullname'] == 'node_counter.totalcount') {
         $item .= ' <span class="popular-content-count">
(' . views_theme_field('views_handle_field', $field['queryname'], $fields, $field,
      $node, $view) . ')</span>';
}

Any command-line input or output is written as follows:

cd <DRUPALROOT>/sites/all/modules/cck

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: "Enable the core Search module and the Views Fast Search module".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply drop an email to , and mention the book title in the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/6965_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.