| Project: | Node Comments |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
After fixing some other issues and applying some patches, I had a user message me about forum replies not working right. I've spent three days trying to track this down and have discovered the following:
When creating your own content type for Node Comments to be used, for example, with Forums, don't use an underscore (_) in the machine-readable name of the content type or nodecomment_get_comment_types() will never match the URL.
From Add New Content Type -> Type: This name must contain only lowercase letters, numbers, and underscores. Underscores will be converted into hyphens when constructing the URL of the create content page.
As it says there, the underscores will be converted to hyphens when it constructs the URL. This includes replies.
So, to illustrate:
If your content type for forum replies (using Node Comments) is forum_reply, the URL for replying to a post is: www.example.com/node/add/forum-reply/nn (where 'nn' is a nid).
But nodecomment_get_comment_types() will return an array containing forum_reply and will not match the forum-reply as arg(2).
If replies are made this way and you have the comment types set to disable subjects (titles), then you'll also notice that it will require a subject (title) when shown the form to post the reply. And, after posting the reply, the post goes to Never-Never Land since it was posted as if it was posted using Create Content on a Forum Reply content type.
I cured this by renaming my Forum Reply content type to forumreply instead of forum_reply. (Probably could've just as easily called it forum-reply and it would have worked also)
So, for anybody wondering where their replies are going or why you are required to enter a subject (title) when replying to a post and you have your reply type set to a name with an underscore, remove the underscore or change it to a hyphen (-) to correct this behavior.
Also note that you will have to reset your nodecomment type and any type that uses it for comments to use the edited type, since the machine-readable name will no longer exist and will be reset to use Drupal Comments.
Hope this helps someone. ;)
Comments
#1
ouch...I totally forgot that. This core "wtf" stuff hits me not the first time :(
#2
Note that you shouldn't use hyphens in content type names as explicitly told by core. Don't give such bad advices. The proper way to fix it is to fix the bug itself inside Node Comments module
#3
#4
Well, you may want to change the following on your project page (under Step 3 of the installation instructions):
You can even have different comment types for different content e.g. "forum-reply" for forums, "comment" for articles, core comments for news pages, etc.:)
#5
Sure.
#6
I tested the patch, and it indeed seems to fix the issue. Committed.
#7
Automatically closed -- issue fixed for 2 weeks with no activity.