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

Appendix D. Views Hooks for Coders

The following hooks are frequently used by module developers.

Hooks

Description

hook_views_arguments()

Create Views arguments array, including name, help text, handler code, and options

hook_views_default_views()

Create default Views (See Chapter 2, and Appendix A).

hook_views_style_plugins

Create array of style plug-ins. These style plug-ins populate the View Type selection list in the Views UI. (See also Chapter 4, and Appendix C.)

hook_views_tables()

Create tables objects for use by Views

The most common Views hook. See http://drupal.org/handbook/modules/views/apifor more information. Be sure to read Parts 1 to 5.

The following hooks tend to be less well-known and not used as often:

Hooks

Description

hook_views_arguments_alter()

Allow modules to alter the arguments supplied others

See http://drupal.org/node/105620 for more information

hook_views_feed_argument()

Alter Views feed argument

Sample use-case at http://drupal.org/node/333039. Also used by the Existing Nodes Filter module, at http://drupal.org/project/existingnodesfilter

hook_views_post_view()

Alter the output string after the view is rendered. Used by Views' own views_rss module, and by the Calendar module.

hook_views_pre_view()

Alter returned data before it is rendered. Sample use-cases in the Calendar module, and at http://www.onetomany.com/adding_node_counts_view_titles_views_1x.

hook_views_pre_query()

Alter or extend the view query. Used by the i18n and Drupal For Firebug modules.

hook_views_query_substitution()

Run-time query replacement. Used by a new module called Views Menu Nodes, http://drupal.org/project/views_menu_nodes.

hook_views_tables_alter()

Alter views table values. Sample use case for this little-known hook at http://drupalhigh.onsugar.com/2669697.

hook_views_tabs()

Array of tabs. Used by the Calendar module

hook_views_theme_wizard_types()

Add new theme wizard types. Used, naturally, by the Views Theme Wizard module, but like all of these hooks, available for use by other modules, as well.

This table displays relevant hooks from other modules:

Hooks

Description

hook_field_formatter() (From the CCK module)

In the Views UI, formatters created by this hook display as a drop-down list of Field Options. (See Appendix B.)

hook_views_fusion() (From the Views Fusion module)

Provide information on how to join the node tables from other modules. (See Recipe 55.)