We should provide a comments pane similar to the default comments pane that can render either comments or node comments as a ctools content type for full Panels 3 compatibility.

Comments

ayalon’s picture

Sounds very interessting!

electricmonk’s picture

Assigned: Unassigned » electricmonk

I need this so I'm starting development on a bridge module. I'll post a ZIP file here so that it can be integrated into the Nodecomment CVS repository.

I'm only going to implement the Nodecomment Form (add comment form) content type, as the comment display for a node can be added using the Nodecomment default view.

electricmonk’s picture

Status: Active » Needs review
StatusFileSize
new9.23 KB

That wasn't so difficult, it appears.

I've encountered a problem with getting the currently logged in user into the context. Merlin - am i missing something? I've tried to define 'required context' as an indexed array with two required contexts, 'node' and 'user'. Panels then refused to show my content type in the content types list...

Anyway, this should go into the Node Comments code base, I guess. No reason to release it as a separate module.

merlinofchaos’s picture

Quick note: Making the attachment a .zip prevents me from just clicking on it and scanning. =)

electricmonk’s picture

Sorry, I'm on win32. Can you handle it, or should I post a tar.gz file?

On another note, this is mainly intended for the Node comment maintainer, I don't think it belongs inside CTools...

merlinofchaos’s picture

I'm more or less maintaining nodecomment 2.x right now =)

And I can handle it but it just means it'll take me longer to get to it to look at it.

friolator’s picture

FWIW, we installed this last night and have tested it successfully on our setup. Haven't really banged on it very hard yet, but it does seem to work as expected here.

friolator’s picture

Ok, i take it back ;-) We were in the middle of testing advanced forum and panels with nodecomments when I posted that last message about this module getting the nodecomment form to work for us in panels. I think I may have been thinking that we were looking at the correct form, when in fact we weren't.

In any case, I'm completely unable to make this work with a plain vanilla custom content type. WITHOUT using panels, node comment works as expected. However, in Panels, we're unable to get the node comment Comment Form from this module to show up. it's just not appearing, even though it's an option available to us in Panels.

Is there a trick to getting this to work? we're passing it "node being viewed" in the settings window, which is the only option available to us. We would really like to get this working ASAP, or we're going to have to scrap nodecomments for a large part of our site, which we'd really rather not do.

and yes, Comments are set to read/write, so it's not that :-)

Thanks!

friolator’s picture

and if it helps merlin to scan... ;-)

Here's the nodecomment_form.inc content type plugin file from the posted module:

<?php

/**
 * Implementation of specially named hook_ctools_content_types()
 */
function nodecomment_ctools_nodecomment_form_ctools_content_types() {
    return array(
      'single' => TRUE,
      'title' => t('Comment form'),
      'icon' => 'icon_node.png',
      'description' => t('A form to add a new comment (using Node Comments).'),
      'required context' => new ctools_context_required(t('Node'), 'node'),
      'category' => t('Node'),
    );
}

function nodecomment_ctools_nodecomment_form_content_type_render($subtype, $conf, $panel_args, $context) {
  $node = isset($context->data) ? drupal_clone($context->data) : NULL;

  // find out what node type serves as the comment type for this node
  $comment_type = variable_get('comment_type_'. $node->type, variable_get('default_comment_type', ''));
  $comment_type_info = node_get_types('type', $comment_type);
  
  $block = new stdClass();
  $block->module = 'nodecomment';
  $block->delta  = $node->nid;

  $block->title = t('Add @type', array('@type' => $comment_type_info->name));

  if (empty($node)) {
    $block->content = t('@type form here.', array('@type' => $comment_type_info->name));
  }
  else {
    if (user_access("create $comment_type content") && $node->comment == COMMENT_NODE_READ_WRITE) {
      ctools_include('form');

      //FIXME this is bad practice but I couldn't figure out how to get the currently logged in user into context
      global $user;	
      
      // create basic comment node 
      $comment = array(
	      'uid' => $user->uid,
	      'name' => $user->name,
	      'type' => $comment_type,
	      'comment_target_nid' => $node->nid,
	    );
      
      $form_state = array(
        'ctools comment alter' => TRUE,
        'args' => array($comment),
      );
      
      // make sure node.pages.inc is loaded
      module_load_include('inc', 'node', 'node.pages');
      
      $block->content = ctools_build_form("{$comment_type}_node_form", $form_state);
    }
  }

  return $block;
}

function nodecomment_ctools_nodecomment_form_content_type_admin_title($subtype, $conf, $context) {
  return t('"@s" comment form', array('@s' => $context->identifier));
}

function nodecomment_ctools_nodecomment_form_content_type_edit_form(&$form, &$form_state) {
  // provide a blank form so we have a place to have context setting.
}

/**
 * Alter the comment form to get a little more control over it.
 */
function nodecomment_ctools_nodecomment_form_form_alter(&$form, &$form_state) {
  if (!empty($form_state['ctools comment alter'])) {
    // force the form to post back to wherever we are.
    $url = parse_url($_GET['q']);
//    $form['#action'] = url($url['path'], array('fragment' => 'comment-form'));
//    if (empty($form['#submit'])) {
//      $form['#submit'] = array('comment_form_submit');
//    }
    $form['#submit'][] = 'nodecomment_ctools_nodecomment_form_submit';
  }
}

function nodecomment_ctools_nodecomment_form_submit(&$form, &$form_state) {
  $form_state['redirect'][0] = $_GET['q'];
}
?>
michelle’s picture

Anyway, this should go into the Node Comments code base, I guess. No reason to release it as a separate module.

Yeah, I took a peek at it and I don't see any reason to have that as a submodule. Haven't tested it, yet. Just eyeballed the code. Maybe you could re-roll it as a patch?

Michelle

electricmonk’s picture

@friolator - Can you try to debug this and see where it fails? are you sure that the user trying to see the comment add form has the correct permissions (create content) and that the content type and content itself has comment status set to read/write?

@michelle - sure, I'll do that when I'm in the office tomorrow. But let's make sure it works first :)

- Shai

friolator’s picture

I've so far only tested this as user 1, so I would have full permissions to create/edit the content (though, there are three roles that do have permission to create/edit these content types as well, and it doesn't work with them either). Comments are read/write on both the base content type and the comment content type attached to it (both use node comments).

Everything that surrounds the form is appearing (my view that shows the node you're responding to and a pane that contains a divider/button bar, as well as the nodecomments that already exist, using the supplied nodecomment view.

Everything is stock, in that I haven't modified anything - latest Views 6.x-2.x-dev, Panels RC1, Ctools RC1, Node Comment 6.x-2.x-dev. However, I have applied (manually) this patch: http://drupal.org/node/502714 to re-enable the "disabled" setting on comment read/write, because it was always coming up disabled.

if there's any more info you need, let me know.

electricmonk’s picture

@friolator - please verify that the note being viewed (not the content type) has comment status set to read/write.

Can you try using a debugger on the module and see where it fails? it would probably help a lot.

friolator’s picture

I just checked again, and everything including the base node has comment status set to read/write. As I posted earlier, outside of Panels, nodecomments are behaving as expected. but within Panels, they don't.

We have worked around this, by the way, by using Panels to override the node/add page for the nodecomment type, and to display the node add form for the node being viewed. We've set nodecomments so that the comment form is always on a separate page, and this seems to work for us, though it's obviously not ideal in that we can't have an inline comment form below comments.

I don't have any debuggers installed, sorry.

dark.o’s picture

Since nobody is reading my other posts and questions regarding node comments for months, i will post this here, since there is some actions. Simple problem, after a while of using node comments, it changes comment settings on the node type that uses node comments. I can not set read/write setting for node comment type! Any idéas why? Each time I set it to read/write, and than check back, the setting is back to "disabled", resulting the link "comment here" on the blog entry disappears. This happens only with 6.x-2.x-dev version (if i understand it right, i need regular comments module enabled with this, it is required?)

And I will not use the old one, since the great thing about 2.version is that node comment title actually links as the comment, not the node. So, any help, suggestions? Thanx

michelle’s picture

@dark.o: That has nothing to do with this issue. Just because the other issue hasn't been addressed, yet, is not a reason to post completely off topic here. Node comments 2.x is still in development, not even alpha, not even listed on the project page, yet. The bugs will get fixed but you need to be patient.

Michelle

dark.o’s picture

oki, thanx for the reply michelle. Tell me where and I will provide you with bug-list since I have been testing it lately quite a lot. no more off topics here. cheers.

michelle’s picture

@dark.o: Just file issues for the bugs here in this queue, one issue per bug.

Michelle

electricmonk’s picture

@friolator - definitely works for me. Can you either:
a) place some print_r or var_dump instructions in strategic places inside the code and see where it fails or
b) send me a complete DB dump + codebase for your project so that I can debug it myself

Thanks

- Shai

andrewlevine’s picture

StatusFileSize
new4.33 KB

I took electricmonk's patch, cleaned it up a bit, and made it work with comment.module when necessary like earl requested. Also integrated it with nodecomment instead of making a separate module with one hook.

andrewlevine’s picture

StatusFileSize
new4.37 KB

one small mistake with previous patch

merlinofchaos’s picture

Status: Needs review » Fixed

Thanks for the work on this everyone! Committed!

Status: Fixed » Closed (fixed)

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

gabash’s picture

Category: task » bug
Status: Closed (fixed) » Active

when implementing the Nodecomment form on panels I am getting this error:
"warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, '_node_form' was given in /var/www/guysadot.com/includes/form.inc on line 371."

nodecomment 6.x-2.0-beta1
panels 6.x-3.2
ctools 6.x-1.2

gabash’s picture

OK, found this patch, http://drupal.org/node/600898

crea’s picture

Category: bug » task
Status: Active » Closed (fixed)
sheise’s picture

Hi,

Sorry to post on this older issue.

I can't find the option to add the nodecomment form in the panel? I can only find the option for Node->Comment form but that simply gives me the Drupal comments form and not my nodecomment content type.

I'm using
Panels 6.x-3.5
Node Comment 6.x-2.0-beta5
Ctools 6.x-1.7

What am I missing? Is this only available in the dev version?

sheise’s picture

Sorry, that was a stupid question! Of course all I needed was the dev version of nodecomments!