3

I am using the Answers module 7.x-4.0-rc2. I would like to have links to different displays of the questions view so that one link goes to only unanswered questions and the other link shows all. When I go to filter options, I'm not sure how to filter the content by if there is an answer or not.

This is done on the demo site but out of the box, the 7.x-4.0-rc2 version of the module doesn't have any special views. See screenshot of the demo site below.

enter image description here

Edit: When attempting to import views from https://www.drupal.org/node/2783513#comment-11516603 as suggested, I get the following errors for rankings.txt, repeated:

  • Style plugin datatables is not available.
  • Field handler userpoints_total.points is not available.
  • Field handler userpoints_total.last_update is not available.
  • Sort criterion handler userpoints_total.points is not available.
  • Unable to import view.

When importing questions.txt, I get:

  • Style plugin datatables is not available.
  • Field handler userpoints_total.points is not available.
  • Field handler field_data_field_tags.field_tags is not available.
  • Relationship handler userpoints_total.uid is not available.
  • Unable to import view.

I attempted installing answers_userpoints (which is uninstalled) but could not do so because it depends on userpoints_rules, which couldn't be found or downloaded.

Edit 2: I took a look at the code for the exported view for unanswered questions, and believe that section I need to replicate is the following portion; this issue I am having is that COUNT(Flags: Flagged) doesn't seem to be available as a filter but I do have flag enabled.

/* Filter criterion: COUNT(Flags: Flagged) */
$handler->display->display_options['filters']['flagged']['id'] = 'flagged';
$handler->display->display_options['filters']['flagged']['table'] = 'flagging';
$handler->display->display_options['filters']['flagged']['field'] = 'flagged';
$handler->display->display_options['filters']['flagged']['relationship'] = 'flag_content_rel';
$handler->display->display_options['filters']['flagged']['group_type'] = 'count';
$handler->display->display_options['filters']['flagged']['operator'] = '!=';
$handler->display->display_options['filters']['flagged']['value']['value'] = '1';
  • Wouldn't it just be a View with a menu tab set on this menu item (the hook_menu item path, not aliased path)? – Kevin Jun 8 '17 at 19:43
  • Okay but how do I specifically list just the answered questions and also the unanswered questions? I basically just want to know how to do this like it is on the demo site. I don't how to use hooks. – Christia Jun 8 '17 at 19:44
  • I assume that this module has Views integration, and you can set contextual filters to query for answers with no value. But for menu tab/tasks to be output by Views, you will need to know the path (i.e. node/%) that Views can attach to in order to create the tab. This can be found quickly by looking at the hook_menu implementation for the Answers module. – Kevin Jun 8 '17 at 19:50
  • Okay thanks. I was hoping the module worked like the demo site out of the box or that there was a simple configuration. It does use views. I'll try your suggestion. – Christia Jun 8 '17 at 19:53
  • Here is an example to get the tabs part, refer to this (steps 1 and 2, ignore the hook stuff) tylerfrankenstein.com/code/… – Kevin Jun 8 '17 at 19:55
3

The demo site related to the 7.x.-4.x version of the Answers module uses a further enhanced version of the most recent dev release. Some of the views have been enhanced and will be pushed to D.O soon. These views are available already in Views Export format via files attached to comment #5 in issue #2783513).

The (new) view related to the questions has a tab titled "unanswered", which contains the list of all questions that are "unanswered".

So to actually answer your question, I suggest you experiment a bit with the updated view of questions as contained (in export format) in the issue mentioned above.

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

  • Thank you! I am unfortunately unable to import the view but I might be able recreate the view by looking at the code. From the summary of the module's functionality on Drupal.org, do these exported views also provide the following: questions/start_ask and questions/search? – Christia Jun 9 '17 at 21:41
  • 1
    hey @Christia , I noticed your update to this question. But what is the current status about your prior comment? ie why were you unable to import the view, like what error did you get? Could it maybe have to do with the "datatables" module that is also used on the demo site? I'd be happy to help you to get that import to work for your site ... ok? – Pierre.Vriens Aug 10 '17 at 23:07
  • @Christia wow, lots of updates ... Here is the very first part to try to get you going: "userpoints_rules" is a submodule of userpoints, the GIT repository of it is located here ... If you have userpoints enabled, you should also be able to see/enable the userpoints_rules submodule. After you resolved that part of your question, please rework your Edit1/Edit2 to reflect the remaining issues left, ok? – Pierre.Vriens Aug 11 '17 at 14:28
  • @Christia and here is a 2nd update (to reduce the errors in your edit1/edit2): the views style used is "data tables", which you will get avilable if you enable the DataTables module (BTW: great module to improve "any" view ... IMO). – Pierre.Vriens Aug 11 '17 at 14:33

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.