Posted by santhonys on August 22, 2008 at 7:47pm
| Project: | Disqus |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
Hi guys,
Thanks for the great module. But, I updated today, and it looks like the new views integration broke my site. I was getting:
Fatal error: Class views_handler_field_node_disqus_comments: Cannot inherit from undefined class views_handler_field_node_link in .../html/modules/disqus/disqus.views.inc on line 22
I removed the disqus.views.inc file to get the site back up, but thought you should know.
I'm running:
Drupal 6.3
Views 6.x-2.0-rc1
Comments
#1
Very strange that views_handler_field_node_link isn't available..... Has anyone else ran into this?
#2
Confirmed. The Views integration needs a patch ;-) . It does this only when the Views API hook is in there.
#3
The Views integration is missing the "parent" class value.
#4
Guys, I am not sure if this is the same issue since I am not receiving any errors or such.
But for the life of me, I cannot find disqus hook on views. Maybe I am blind, but where am I supposed to look for it in views under node type?
thanks!
#5
It's not enabled because it's broken. I think it needs a "parent" class value. Take a look at disqus.views.inc.
#6
subscribing
#7
I have some highly customized layouts using Views and I am trying to get the "# of comments" link to show up on the different entries on the pages and blocks. So the number of comments link shows up on a view when the type is Node, but if the row style is fields, it does not show up (or I can't figure it out). How can you add it to a view display with fields? I looked at the different types of layouts and I could not find it in any of the different setting pop-ups. Is there something one has to do to get the discus comment count to show up on any view other than Node view inside the a views' configuration area? Thanks.
#8
Attached is a patch for version 6.x-1.5, upgrading the module to use the new Views 2 API. The new API requires that each handler class be contained in its own include file, so that file is attached along with the patch. The new file should be placed directly in the root of the "disqus" module directory and renamed to "views_handler_field_node_disqus_comments.inc".
#9
Seems #8 is implemented in the latest release? However I still can't get it working with View fields. To get this working I made the following modifications:
File: disqus.views.inc
// $Id: disqus.views.inc,v 1.1.2.4 2009/08/27 23:40:14 robloach Exp $
/**
* Implementation of hook_views_data_alter.
*/
function disqus_views_data_alter(&$data) {
// Number of Disqus comments made on the given node.
$data['node']['disqus_comments'] = array(
'field' => array(
'title' => t('Disqus: Comments'),
'help' => t('The number of Disqus comments made on the node.'),
'handler' => 'views_handler_field_node_disqus_comments',
),
);
}
/**
* Implementation of hook_views_handlers().
*/
function disqus_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'disqus') . '/include',
),
'handlers' => array(
// field handlers
'views_handler_field_node_disqus_comments' => array(
'parent' => 'views_handler_field',
),
),
);
}
create a folder named include, add a file named views_handler_field_node_disqus_comments.inc with the following code:
<?php
/**
* Field handler to present the number of Disqus comments on a node.
*/
class views_handler_field_node_disqus_comments extends views_handler_field {
function init(&$view, $options) {
parent::init($view, $options);
}
function query() {
// Override parent::query() without altering query.
}
/**
* When rendering the field.
*/
function render($values) {
// Ensure Disqus comments are available on the node user has access to edit this node.
$node = node_load($values->nid);
if (user_access('view disqus comments') && isset($node->disqus)) {
return theme('disqus_comments_num', $node->disqus['domain'], $node->disqus['url']);
}
}
}
Add the following code at the bottom of disqus.module
/*** Implementation of hook_view_api().
*/
function disqus_views_api() {
return array('api' => 2);
}
#10
Like this?
#11
Looks right!
#12
RTBC.
FYI, this won't work on the view preview because the requisite JS won't be loaded. It might be appropriate to make a note of it in the handler's help text.
#13
Thanks! http://drupal.org/cvs?commit=343548
#14
Automatically closed -- issue fixed for 2 weeks with no activity.
#15
I'm opening this back up because I really can't find the Disqus comment count on Views anywhere -- this should show up in a node-type views underneath the 'sort' menu part, right? I can't find anything there..
#16
What version are you on? Could you try -dev? Do we need a new release?
#17
@ #15, there is a field handler, but no sort handler. You can display the comment count as a field, but you can't sort on the field.
As far as I know, the field's not numeric anyway. The output of the field can be something like "20 comments and 14 reactions".
This'll show if you've got both comments and reactions enabled in the disqus domain settings. It'd be difficult to make a nice sort on that.
#18
hello @#17 basvredeling
When you said "It'd be difficult to make a nice sort on that" where is the problem in views integration with Drupal or in Disqus API.
Regards,
enzo
#19
@-enzo-
I don't know where the problem lies exactly. But the field disqus_comments is actually 2 fields (depending on your disqus configuration): comments and reactions. So views integration should split those up and make them both numeric in order to do proper sorts on them. If that is at all possible with the disqus api of course.
#20
I just installed it and only see one item in views which is the node item comments count is there any other view item for fields?
#21
#1095194: Disqus Migration module revamp... Would be nice to cache the comments in the Drupal database so that we could do this kind of this with it.
#22
I've created a simple module that updates the comment count statistics for nodes from Disqus. You might want to check it out here: http://andreigherasim.net/disqus_comment_count/
#23
sub
#24
hi andreigg,
i tested your module and it works perfectly.
thank you!
#25
andreigg: Wow, just what I have been looking for! This should be a sub module for disqus. Could you include it?
#26
Nice work andreigg! A note to others using this module, you'll need the core comments module enabled (and not the statistics module - as I originally presumed).