Not sure where the problem is, but I tried today to put the comments into a region of a custom display mode. The comments weren't being rendered at all.

I tried doing exactly the same set up (same layout, same field config) on the default view mode and it did work, so I think it's to do with comments on a custom display mode.

I got round it by using a dynamic field which displays the comments, but the comments field should work on custom display modes, or it shouldn't be an option.

CommentFileSizeAuthor
#2 1512316-2.patch411 bytesswentel

Comments

swentel’s picture

It's core's fault that they aren't rendered:

    // Inside comment_node_view()
    if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
      $node->content['comments'] = comment_node_page_additions($node);
    }

But it's rather easy to remove them from other view modes. I'll post a patch this weekend.

swentel’s picture

Status: Active » Fixed
StatusFileSize
new411 bytes

patch attached, committed and pushed.

Status: Fixed » Closed (fixed)

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

rpmskret’s picture

Version: 7.x-1.4 » 7.x-1.5
Status: Closed (fixed) » Active

Hi. I was very glad to see this post. Very same issue for me. I have applied the patch by swentel and that did not make any noticeable change. But thank you swentel for the pointer to comment_node_view() . I made a hard code fix. Bad way to go but it's quick and effective to be forward about it. Not a very good or long term solution for sure.

		// Inside comment_node_view()
		// My custom view mode = 'wideds'
    if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
      $node->content['comments'] = comment_node_page_additions($node);
    }
   if ($node->comment && $view_mode == 'wideds' && node_is_page($node) && empty($node->in_preview)) { // @RS added this if block
      $node->content['comments'] = comment_node_page_additions($node);
    }

It is very good of you swentel to reply as you did, incredibly 5 minutes after the original post!
If you find time and a way you will get a proper fix for ds for this issue. Otherwise, we at least can apply an emergency fix by personal choice.

swentel’s picture

Status: Active » Closed (fixed)

There's nothing further I can do.

andrewbelcher’s picture

I needed a solution to this one... So I came up with one that met our needs, should meet the needs of @romanse and could be extended to a more generic solution that could be included in DS (though probably more likely DS Extras).

I used a hook_node_view() to attach comments in the situations where comments_node_view() wasn't but I needed them. For my situation I just hardcoded in a custom module the display modes I wanted to attach comments to, but probably a more viable solution which doesn't unnecessarily load comments for view modes that don't need it would be to have a settings page for it that lets you choose which view modes to load comments for.

When I get the time I'll put it together into a module sandbox and then it can either be used independently or brought into Extras....

rpmskret’s picture

@ andrewbelcher, I am not yet up on making modules. Soon I think I will make time.
But I am glad to see your post and your fix, being a better alternative to editing core code.
I'll have a look if/when you do get your module posted.

rpmskret’s picture

I wish to add another core code edit alternative. If you take it upon yourself to edit the core to fix this issue, I have found a very simple edit which is working thus far. I tried a few tests and this works 100% so far.

    // Inside comment_node_view() , ORIGINAL CODE.
    if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
      $node->content['comments'] = comment_node_page_additions($node);
    }

    // Inside comment_node_view() , EDITED CODE.
    if ($node->comment && node_is_page($node) && empty($node->in_preview)) {
      $node->content['comments'] = comment_node_page_additions($node);
    }

As you can see I have simply removed the requirement for the node $view_mode to be of any particular type.

rodrigoaguilera’s picture

Status: Closed (fixed) » Active

I'm experiencing this on DS 2, the comments field it's only available on the full content view mode ¿is this the normal behaviour?¿Should I add a extra field for comments?

swentel’s picture

Status: Active » Closed (works as designed)

Yes, it's the normal behavior embedded in core.