I'm developing a website with content type that needs to have the following functionalities:
- Custom fields (not a problem)
- User comments (not a problem)
- Questions (from any user) & answers (restricted to website editor/owner)
Imagine the following use case: We have a website that is publishing reviews of some products (node with custom fields) and the product page also has a section for comments and questions & answers (Q&A). I know they are quite similar but my customer wants it distinctly separated. So, the section for comments is standard and is nicely covered by Drupal's default module. However, I'm having problems finding a solution for the questions & answers section, which works like this: (1) someone reads the product description and (2) has a very specific question about the product that needs to be answered by the website editor. Therefore, answers can only be given by website editor/owner, not any (un)registered person.
My question is: Is there any such module that has the required Q&A functionality? I've been searching extensively and I could not find any such module, but I might have overlooked something. So the next questions is: Are there any modules that could be "hacked" with minimal effort to provide such functionality. The third option is probably to code something from scratch. Any recommendations on how to approach that?
Any help, hint, direction would be much appreciated.
Thanks.
Comments
There are some additional
There are some additional details I'd need to know to provide a comprehensive solution, but this approach should get you started.
Create a new question/answer content type with (at minimum) these fields:
- Question
- Answer (use Field Permissions to restrict edit access to admins)
- A hidden entity reference field that references the node that the question is being asked about.
In the view displaying the product, provide a link to a question submission form. This link should include an argument with the node id, which will populate the entity reference field. This will associate the question with the product.
This should at the very least get you started.
Thanks for the proposed
Thanks for the proposed solution. I was thinking about something like that but didn't know how to implement it.
I know how to add link to the node view, but could you be a bit more specific what should I use for submission form? Do direct the user to the /node/add/product?
Another question is how do I pass the node id to populate the reference field? Do I have to code it manually or there is some existing mechanism?
Thanks for your help.
This can be approached via
This can be approached via code or the prepopulate module. (Full disclosure, I haven't personally used prepopulate before, but I've seen it used to accomplish what you need to do)
The example on the module download page is structured the same way your URL will need to be, so you can use that as a template for creating the link to the form.
If you're interested in going the code direction, I can assist with that as well.
I will first try the
I will first try the prepopulate module and let you know how that goes.
Thanks.