Last updated March 26, 2011. Created by joachim on November 19, 2007.
Edited by linclark, totsubo, mroswell, Darren Oh. Log in to edit this page.

(Note: this is pretty basic, based on what I've learned making one of these myself.)
(Note: this documentation is only applicable to Views 1)

A style plugin controls how the nodes that a view's query returns are presented to the user. Each style plugin shows in the View Type property in a View's Page and Block options. The basic Views module comes with several style plugins already installed: Full Nodes, Teaser List, Table View and List View for example. Other modules (such as Calendar) add further plugins.

Declare the plugin: hook_views_style_plugins

To declare a new style plugin, your module must implement hook_views_style_plugins. This function should return an array of all the style plugins you wish to use.

Here's an example for a list style plugin:

function mymodule_views_style_plugins() {
  $items['my_list_style_plugin'] = array(
    'name' => t('Display name'),
    'theme' => 'my_list_style_plugin_view',
    'validate' => 'views_ui_plugin_validate_list',
    'needs_fields' => TRUE,
    'weight' => 0,
  );
  return $items;
}

and here's one for a table style plugin:
function mymodule_views_style_plugins() {
  $items['my_table_style_plugin'] = array(
    'name' => t('Display name'),
    'theme' => 'my_table_style_plugin_view',
    'validate' => 'views_ui_plugin_validate_table',
    'needs_fields' => TRUE,
    'needs_table_header' => TRUE,
    'weight' => 0,
  );
  return $items;
}

Here is an explanation for the array items shown above:
$items['my_list_style_plugin']
This identifies your plugin internally. The key should be unique. It's a good idea to begin this key with your module name to ensure this. The key is limited to 20 characters.
name
The name of the plugin style that is shown to the user.
theme
The theming callback function. The function defined here will do the actual work of creating the style plugin, eg theme_my_list_style_plugin_view().
validate
The validating callback. The Views_UI module defines two that you can use: views_ui_plugin_validate_list and views_ui_plugin_validate_table (though these are in fact identical). If your plugin needs certain elements in order to make sense, such as particular fields, you can define your own validating function. See below.
needs_fields
Either TRUE or FALSE. If true, the user must select at least one field in the views UI.
needs_table_header
Either TRUE or FALSE. Table style plugins should set this value to TRUE or otherwise the plugin will not be able to display the headers in the table.
weight
weight in the View Type options list shown to the user

even_empty is an additional boolean item which calls the plugin theme even if there are no results. This item was restored to Views in May 2008. http://drupal.org/node/259560

Theme the plugin

The hook_views_style_plugins implementation defines a theming function for your plugin. You need to create a function theme_my_list_style_plugin_view which controls the display of the nodes. The views module itself is a good source of examples. Here's a basic template:

function theme_views_view_list($view, $nodes, $type) {
  $fields = _views_get_fields();
  foreach ($nodes as $node) {
    $item = '';
    foreach ($view->field as $field) {
      // build up $item for each field
    }
    $items[] = ""; // store the HTML for one item in the array
  }
  if ($items) {
    return theme('item_list', $items);
  }
}

Validator functions

These have arguments: ($type, $view, $form). The function is called twice, with $type set to 'page' and 'block. The $view is an array rather than an object.

See here for an example of a validator to check specific fields are present: http://drupal.org/node/370593

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.