You are here

function quotes_views_tables in Quotes 5

Implementation of views_tables().

File

./quotes_views.inc, line 11
This is the stuff to make Views work for the Quotes module.

Code

function quotes_views_tables() {
  $tables['quotes'] = array(
    'name' => 'quotes',
    'provider' => 'internal',
    // won't show up in external list.
    'join' => array(
      'type' => 'inner',
      'left' => array(
        'table' => 'node',
        'field' => 'vid',
      ),
      'right' => array(
        'field' => 'vid',
      ),
    ),
    'fields' => array(
      'aid' => array(
        'name' => t('Quotes: Author link'),
      ),
      'citation' => array(
        'name' => t('Quotes: Citation'),
        'sortable' => TRUE,
        'help' => t('This will display the source of the quote.'),
      ),
    ),
    'sorts' => array(
      //      'author' => array(
      //        'name' => t('Quotes: Author Name'),
      //        'help' => t('This allows you to sort alphabetically by author.'),
      //        ),
      'citation' => array(
        'name' => t('Quotes: Citation'),
        'help' => t('This allows you to sort alphabetically by the source.'),
      ),
    ),
    'filters' => array(
      //      'author' => array(
      //        'name' => t('Quotes: Author Name'),
      //        'field' => 'author',
      //        'operator' => 'views_handler_operator_or',
      //        'list' => 'quotes_get_authors',
      //        'help' => t('This allows you to filter by a particular author.'),
      //        ),
      'citation' => array(
        'name' => t('Quotes: Citation'),
        'field' => 'citation',
        'operator' => 'views_handler_operator_or',
        'list' => 'quotes_get_citations',
        'help' => t('This allows you to filter by the source.'),
      ),
    ),
  );
  $tables['quotes_authors'] = array(
    'name' => 'quotes_authors',
    'provider' => 'internal',
    // won't show up in external list.
    'join' => array(
      'type' => 'inner',
      'left' => array(
        'table' => 'quotes',
        'field' => 'aid',
      ),
      'right' => array(
        'field' => 'aid',
      ),
    ),
    'fields' => array(
      'aid' => array(
        'name' => t('Quotes: Author ID'),
        'sortable' => TRUE,
        'help' => t('This links the author to the quote.'),
      ),
      'name' => array(
        'name' => t('Quotes: Author Name'),
        'sortable' => TRUE,
        'help' => t('This will display the author of the quote.'),
      ),
      'bio' => array(
        'name' => t('Quotes: Biography'),
        'sortable' => TRUE,
        'help' => t('This is the author\'s biography.'),
      ),
    ),
    'sorts' => array(
      'Name' => array(
        'name' => t('Quotes: Author Name'),
        'help' => t('This allows you to sort alphabetically by author.'),
      ),
    ),
    'filters' => array(
      'name' => array(
        'name' => t('Quotes: Author Name'),
        'field' => 'name',
        'operator' => 'views_handler_operator_or',
        'list' => 'quotes_get_authors',
        'help' => t('This allows you to filter by a particular author.'),
      ),
    ),
  );
  return $tables;
}