I am trying to create a view mode that gives a content editor the option of selecting the view mode, so that they can display different fields. I was trying to do this for a single node display and just noticed that the comments field (which displays all the comments for the node) is not available in my view mode. I have looked through all my view modes to see if they have that field and they do not. Only the standard "full content" view mode has the comments template.
Is there a way to include the the comments field in a custom view mode? I am sure one can do it via a custom code field, but it seems that one should have the option of adding it by default through the GUI. Perhaps I have something configured wrong in the GUI that is not making the comments thread available as a field in the view mode?
Would appreciate some help with this & thank you!
Comments
Comment #1
RKopacz commentedOk so I tried printing the comment variable in the display suite custom code section:
Doesn't work. Any thoughts on this? Would appreciate some help.
Comment #2
RKopacz commentedOk never mind. I figured it out. You can create a dynamic field which will be available to the view mode, which will display the node's comments. Any one who isn't sure how to do it can watch this video at Drupalize.me, which explains how to do it.
While it's good that Display Suite can do this, I do think the comment field which is available to the full content view should also be available to other view modes by default, without having to go through all that.
Hope this helps someone, a least.
Comment #3
rajmataj commentedWould you mind outlining what exactly you're putting into the dynamic field to get it to show the comments? I have seen the video and tried selecting node > comments for the content but still had no luck.
On a different but related note, I noticed something weird for the comments.
Any kind of definitive way to assign Comments to a region in a Display Suite view mode would be super helpful. At least this is now working for me but I'd like to understand why. Again, please @RKopacz if you could also provide the code or steps you took with the dynamic field to get comments to show, please reply here. Thanks! Display Suite is an awesome module.
Comment #4
oeroek commentedGreat help. I ran into exactly the same problem and the video at drupalize.me pointed me in the rigt direction. Basically you need to do the following.
If you have a custom view mode it seems that comments and comment form are not shown as a Display Suite field. In full mode the are.
You make 2 dynamical fields. Name is of no importance. On your custom view mode you move both fields into the content so they are visible. In the settings of each field you can select the content that should be shown. The first field: node->node comments. The second field: node-> comment form. Save and youre done.
Comment #5
deakbalazs commentedComment module is hardcoded for 'full' view mode, but you can turn on comments for other node voew modes via hook_node_view(). Here is an example:
Also you can define special view mode for comments via kormanyablak_entity_info_alter() :
This will show a new view mode tab on the contettype's structure comments display settings admin-page.
Comment #6
webservant316 commentedI am trying to use the code suggested in #5. comment_node_view() is called, but comments still do not display. any ideas?
Comment #7
proweb.ua commentedsame problem
Comment #8
webservant316 commentedI figured it out instead by using DS Dynamic Fields and choosing the comment field for display.
Comment #9
nikolay borisov commentedSaw there is no working answer here.
I am really not a fan of DS but I had to do it for an inherited project and here is a solution that works:
You could create a Code field, select for Entities : Node, and for code the following:
Then you just have to drag it in your display.
Comment #10
webservant316 commented#8 is also a working answer.
Comment #11
nikolay borisov commentedin my case it was not working (maybe because the display was used for a node from a View)
Comment #12
AndersEkman commentedAnother way to solve this is by creating a view that displays the comments, and then attach it to the desired view mode using the Entity Views Attachment module.
Some tips: