I want to create a question/answer block.

I guess I need to create a content type, turn comments on, and in page.tpl.php display nodes with comments. It should appear as in the image below.

enter image description here

What's the easiest way to get that block?


I decided to use 2 content types, one for question and another for answers, and link each other with node reference.

For example any registered user on the site can write a question, but only moderators can make answers on their questions. When moderator does node/add/answer he/she chooses with a select list to which node the answer would be linked.

Is this a right solution?

  • Could you revise your question to clarify what you are trying to accomplish?
    – Ashlar
    Dec 17, 2011 at 0:46
  • I need functionality like chat. You can write your question and as comment some of user might answer on your question. Thats all Dec 17, 2011 at 7:24
  • Maybe you should consider using the Forum module for this. Dec 18, 2011 at 2:36

2 Answers 2


If you just want to create a node where a user writes a question to which the other users answer using comments, then you can use a content type that Drupal has by default. For example, with Drupal 7 the "Article" content type has already what you need; an article appears as in the following screenshot:


The only things that would need to be changed are the subject of the comment, that should not be entered, and the string "Add new comment" that should be changed in "Add new answer."
For the first, you need just to change the settings for the content type.


If you deselect the highlighted checkbox, the user will not be able to enter a title for the comment.
The other option to which you could be interested is the following one:


When it is selected, any comment for a comment is shown indented. As the comments for the node are the answers given to the question, any comment for the answer should be indented, or it would not be possible to understand when a comment is an answer, or a comment for an answer (or a comment to a comment given to an answer).

For changing the string from "Add a new comment" to "Add a new answer," you need a custom module that changes that string. For this reason, I would create a content type copying the setting used for the "Article" content type.

You don't need to alter the page.tpl.php file to show the comments together the node: That is what Drupal normally does. There is a module that allows to shows the comments in a different tab, but without that module, Drupal shows the comment in the same page where a node is shown. You will eventually need to change a template file to change the layout of the comments, though.

If you are using the word block to mean Drupal block (e.g. you want to show a block for asking a new question), then that is not possible without using third-party modules. I am not sure there is already a module for that.

  • Thanks, by the way im working with D6 not D7. I decided to use 2 content types, one for question and another for answers, and link each other with node reference. For example any registered user on the site can write a question, but only moderators can make answers on their questions. When moderatr does node/add/answer he chooses with select list to which node his answer would be linked. Is this a right solution, kiamlaluno? Dec 18, 2011 at 15:14
  • Your solution has the pro of resolving the problem of the comments that would have two different purposes: being the answer to the question, and being the comment for a given answer. It also allows to give the permission of answering to some users, and the permission of commenting the answers to different users; if comments were used in both cases, it would have been more difficult to limit who can answer, and who can comment those answers. Your solution also allows you to have a view of the answers, and a view of the questions.
    – apaderno
    Dec 18, 2011 at 15:45
  • So you think its good? Dec 18, 2011 at 17:26
  • Yes, I do. It also avoids the problem of the text saying, "Add a new comment," when it should say, "Add a new answer." On the other side, the Project issue tracking module uses comments, and not a new content type for the follows-up to the issues. It all depends from how much code you are willing to write, and in which way you want to customize the Q/A views.
    – apaderno
    Dec 18, 2011 at 17:32

This question dates from the D6 days. These days, for D7, "there is a module for it", which IMO does what you're looking for, and actually much more, as further detailed below: the Answers module. Here are some details about it (from its project page):

Answers enables the implementation of a Question & Answer system in a Drupal site. Users can post questions and other users can answer them.

Head over to its project page for more details.

At its core, this module exists of 2 typical content types:

  • Question.
  • Answers.

The "Best Answer" submodule can be used so that the question author can "accept" one of the answers as the best one. And you could make the Rules module to either trigger all sorts of subsequent things to happen "when an answer gets marked as best answer", or to add all sorts of validations when posting an answer (or question).

The Answers module comes with integrations with other modules such as the Rules module and the Userpoints module and supports voting.


Have a look at the (new) demo site of the Answers module. This link shows various menu options within the block with title Answers Menu, i.e.:

  • Questions (= a view):
    • All: of all existing questions (= default tab).
    • Answered: all questions which have a "best" (= accepted) answer (= sub-tab).
    • Unanswered: all questions which do not yet have a "best" (= accepted) answer (= sub-tab).
  • Answers (= a view): lists all existing answers for any of the existing questions and which does not (yet) have any submenu options (implemented as tabs).
  • Rankings (= a view): contains a list of users with their actual ranking (= reputation points implemented via user points), and with each user a link to either the questions or answers from that user.
  • Ask Question: to post a new question (the equivalent of node/add/question), which is only shown for authenticated users though.

These views also use the dataTables format, but you could easily replace that with any views display format you'd want. And because of the search box that comes with dataTables, there is no need for extra menu links to search within questions, answers or rankings.

These new/enhanced views were created starting from the 7.x-4.x-rc2 release of Answers, and will be included in the next release of it also (together with various other enhancements not yet visibile in the demo site).

Release recommendation

To decide between the 7.x-3.2 and the 7.x-4.0-rc2 release, I would recommend the 7.x-4.0-rc2 . Even though it is not yet an official release, it is fairly stable/functional, and only has a few more minor glitches to be resolved. Pretty soon an rc-3 (the last 'rc' release?) should become available also, which will include the newest features as you can see in the demo site already.

Disclosure: I'm a (co-)maintainer of this module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.