2

I want to use a question and answer system for different subpages. I have many products and on each product page should be a question and answer system. The "Answers" module is good, but I can only configure it for general use. Users can see all questions and answers there.

I want to configure it so that they can only see questions and answers to the specific product (subpage), like these relative paths:

  • /category/product1/question1

  • /category/product1/question2

  • /category/product2/question1

How can I configure the Answers module to get this result?

1

I'm assuming you're using the most recent 7.x.-4.x version of the Answers module. The new demo site uses a further enhanced version of the most recent dev release. For example the views have been enhanced and will be pushed to D.O shortly. These views are available already in Views Export format via files attached to comment #5 in issue #2783513).

Here is a screenprint of the (new) view to show all the questions:

enter image description here

Note the Topics column in the above views result: it's just a term reference field, added as an extra field to the "Question" content type (which comes with the module). With that in mind, you could use a similar approach:

  • Step 1: Add a similar (mandatory) field, I'd recommend an Entity reference field. So that when a question is created the question author indicates which product your question is about.
  • Step 2: Enhance the view to add a filter related to the product.
  • Step 3: Adapt the path of your enhanced view that matches your requirements.

Note: regarding the "...so that they can only see..."-part of your question it may be sufficient to just filter the view as described above. But if you actually want to restrict access to any of the questions, you can use the access method/module of your choice to limit access to the Question nodes. Red flag: be aware of the "Disable Query Rewriting" discussion (and tune that views setting if needed).

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

  • Thanks. I added the Entity reference field. I created a new view which has a relationship to the entity reference field and a contextual filter with Content: Nid. The contextual filter has the relationship to the entity reference. But it does not show any results. I am using the same view settings with the entity reference for a different content type and it works perfectly fine. – Meito Aug 18 '16 at 13:51
  • I remember that I also struggled quit a bit when I worked on those views that you can now find (in export format) in that issue I mentioned. I don't recall though what the actual reason was, but at first my view didn't show any results either. And it's really tough (impossible?) to debug "your" new view you created. Therefor how about this approach: (1) don't use an entity reference yet, but instead use a taxonomy (term) reference, with a machine name as in my exported views (2) import the view(s) in that issue. From then one we "talk about the same thing" ... (see next comment) – Pierre.Vriens Aug 18 '16 at 14:08
  • ... after you get "my" views results reproduced in your setup, you clone that view in something that uses "your" entity reference field instead (and probably remove the taxonomy term). PS: I believe that the tough part of these views was about some relationship between a question and its answers (maybe by just looking at "my" (imported) views you could find out what exactly?). – Pierre.Vriens Aug 18 '16 at 14:11
  • I successfully imported the view from that issue, cloned and changed the contextual filter / entity reference. I am displaying it as a block. The block shows the results on the product pages in accordance with the entity references. Everythings works fine. But now I want to add the block to my QuickTab on the product page. In QuickTab it shows no results, although the separate same block (in the sidebar) shows the results. – Meito Aug 19 '16 at 10:40
  • @Meito : as per your "Everythings works fine" (and what you wrote before that), it looks like you made some (50% ?) progress on what you're trying to get to work. But to be honest your last 2 phrases (But now I want ... shows the results) seem like a new (followup) question. How about you mark this answer as "accepted", and post a new question (referring to this one if you want). The advantage of doing so is that your new question will get way more visibility, and other feedback/answers from more users experienced in views and/or quicktabs. What do you think? – Pierre.Vriens Aug 19 '16 at 11:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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