I'm trying to modify the Annotate views include file in order to create a view that will list all notes for all nodes that belong to a particular group. Below is the code I modified, but it still doesn't seem to be working.

The Annotations table contains the nid which corresponds to a node table nid. The book table will list all node ids (nids) which match a particular parent book id (bid).

I need to set up a relationship in views so that selecting a book id (bid) will list all notes attached to all nodes that belong to that book.

Any suggestions?

annotations

Key: 2 PRIMARY
Key: 1 PRIMARY

uid: int, 11
nid: int, 11
visibility: int, 11
note_format: int, 11
note: longtext, 2147483647
timestamp: int, 11

book

Key: 1 PRIMARY

mlid: int unsigned, 10
nid: int unsigned, 10
bid: int unsigned, 10

node

Key: 1 PRIMARY

nid: int unsigned, 10
vid: int unsigned, 10
type: varchar, 32
title: varchar, 255
uid: int, 11
status: int, 11
created: int, 11
changed: int, 11
comment: int, 11
promote: int, 11
moderate: int, 11
sticky: int, 11
language: varchar, 12
tnid: int unsigned, 10
translate: int, 11

/**
* @file
* Annotate Views support. Declares all the main tables to Views
* @author Frans Kuipers <a href="http://drupal.org/user/103267
" title="http://drupal.org/user/103267
" rel="nofollow">http://drupal.org/user/103267
</a> **/

/**
* Implementation of hook_views_data().
*
* @see _annotate_get_visibility_list()
*/
function annotate_views_data() {
  $tables['annotate'] = array(
    'table' => array(
      'group' => t('Annotations'),
      'join' => array(
        'users' => array(
          'table' => 'annotate',
          'left_field' => 'uid',
          'field' => 'uid'
         ),
         'node' => array(
           'table' => 'annotate',
           'left_field' => 'nid',
           'field' => 'nid'
         ),
/**
* I added 'book' here.
*/
         'book' => array(
           'table' => 'annotate',
           'left_field' => 'nid',
           'field' => 'nid'
         ),
        ),
      'base' => array(
        'field' => 'note',
        'title' => t('Annotation'),
        'help' => t('Notes added as annotations to node content.'),
      ),
    ),
    // Fields definitions
    'note' => array(
      'title' => t('Note'),
      'help' => t('The note text for this node'),
      // Information for displaying the note
      'field' => array(
        'handler' => 'annotate_handler_field_note',
        'format' => 'note_format',
      ),
      'extra' => array(
        array('field' => 'uid', 'value' => '***CURRENT_USER***', 'numeric' => TRUE),
      ),

    ),
    'timestamp' => array(
      'title' => t('Post date'),
      'help' => t('Date and time of when the comment was posted.'),
      'field' => array(
        'handler' => 'views_handler_field_date',
        'click sortable' => TRUE,
      ),
      'sort' => array(
        'handler' => 'views_handler_sort_date',
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_date',
      ),
    ),
    'visibility' => array(
      'title' => t('Visibility'),
      'help' => t('Visibility of the note, 0=private, 1=editor, 2=other, 3=collaborators.'),
      'field' => array(
        'handler' => 'annotate_handler_field_visibility',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_in_operator',
        'options callback' => '_annotate_get_visibility_list',
      ),
    ),
/**
* I added 'bid' here.
*/
    'bid' => array(
      'title' => t('Book'),
      'help' => t('The book the note is annotated to.'),
      'relationship' => array(
        'base' => 'book',
        'base field' => 'bid',
        'handler' => 'views_handler_relationship',
        'label' => t('Book'),
      ),
    ),
    'nid' => array(
      'title' => t('Node'),
      'help' => t('The node the note is annotated to.'),
      'relationship' => array(
        'base' => 'node',
        'base field' => 'nid',
        'handler' => 'views_handler_relationship',
        'label' => t('Node'),
      ),
    ),
    'uid' => array(
      'title' => t('User'),
      'help' => t("The User ID of the note's author."),
      'relationship' => array(
        'base' => 'users',
        'base field' => 'uid',
        'handler' => 'views_handler_relationship',
        'label' => t('User'),
      ),
    ),
    'delete_note' => array(
      'real field' => 'uid',
      'title' => t('Delete annotation'),
      'help' => t('Link to delete an annotation.'),
      'field' => array(
        'handler' => 'annotate_handler_field_note_link_delete',
      ),
    ),
    'edit_note' => array(
      'real field' => 'uid',
      'title' => t('Edit annotation'),
      'help' => t('Link to edit an annotation.'),
      'field' => array(
        'handler' => 'annotate_handler_field_note_link_edit',
      ),
    ),
    // uid alias to filter on current user
    'uid_current' => array(
      'real field' => 'uid',
      'title' => t('Current'),
      'help' => t('Filter the view to the currently logged in user.'),
      'filter' => array(
        'handler' => 'views_handler_filter_user_current',
        'type' => 'yes-no',
      ),
    ),
  );

  return $tables;
}

/**
*  Implementation of hook_views_handlers().
*/
function annotate_views_handlers() {
  return array(
    'info' => array(
      'path' => drupal_get_path('module', 'annotate') . '/views',
    ),
    'handlers' => array(
      // field handler
      'annotate_handler_field_note' => array(
        'parent' => 'views_handler_field'
      ),
      'annotate_handler_field_visibility' => array(
        'parent' => 'views_handler_field'
      ),
      'annotate_handler_field_note_link_delete' => array(
        'parent' => 'views_handler_field'
      ),
      'annotate_handler_field_note_link_edit' => array(
        'parent' => 'views_handler_field'
      ),
    ),
  );
}

Comments

kars-t’s picture

Status: Active » Fixed

Dear fellow Drupal enthusiasts,

this issue is now lasting for a very long time in the issue queue and was unfortunately never solved. As Drupal is a open source project everyone is helping on voluntary basis. So that this is was not solved is nothing personal and means no harm. But perhaps no one had time to deal with this issue, maybe it is too complex or did not describe the problem comprehensibly.

But this issue is not the only one. There are thousands of issues on Drupal.org that have never been worked on or could not be processed. This means that we are building a wave that is unmanageable and just a problem for the Drupal project as a whole. Please help us keep the issue queue smaller and more manageable.

Please read again, "Making an issue report" and see if you can improve the issue. Test the problem with the current Core and modules. Maybe the problem doesn't exist anymore, is a duplicate or has even been solved within this issue but never closed.

Help can also be found for it on IRC and in the user groups.

In order to remove this issue, I have set this issue to "fixed".

If there is new information, please re-open the issue.

--
This issue was edited with the help of Issue Helper

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.