summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2011-06-14 18:45:04 (GMT)
committer Daniel Wehner2011-06-14 18:45:04 (GMT)
commit833071613969ecda8a81e8bd53a2406088ddaf44 (patch)
treeae054ed8a80d0ed560f04a91b2bd23d03d8359fd
parentd816ebd5971d703846a9fadf8e6d771e0e7f061e (diff)
Issue #1187444 by dereine: Make comments an explicit relationship.
-rw-r--r--modules/comment.views.inc22
1 files changed, 17 insertions, 5 deletions
diff --git a/modules/comment.views.inc b/modules/comment.views.inc
index 3f47952..286decd 100644
--- a/modules/comment.views.inc
+++ b/modules/comment.views.inc
@@ -29,12 +29,11 @@ function comment_views_data() {
'help' => t("Comments are responses to node content."),
);
- //joins
- $data['comment']['table']['join'] = array(
- //...to the node table
+ // Provide a "default relationship" to keep older views from choking.
+ $data['comment']['table']['default_relationship'] = array(
'node' => array(
- 'left_field' => 'nid',
- 'field' => 'nid',
+ 'table' => 'node',
+ 'field' => 'cid',
),
);
@@ -532,6 +531,19 @@ function comment_views_data_alter(&$data) {
),
);
+ $data['node']['cid'] = array(
+ 'title' => t('Comments of the node'),
+ 'help' => t('Relate all comments on the node. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.'),
+ 'relationship' => array(
+ 'group' => t('Comment'),
+ 'label' => t('Comments'),
+ 'base' => 'comment',
+ 'base field' => 'nid',
+ 'relationship field' => 'nid',
+ 'handler' => 'views_handler_relationship',
+ ),
+ );
+
}
/**