Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
44.8k views
in Plugins by
Somtimes people don´t ask questions, but publish useful information (in this forum e.g. announcements of new plugins or themes).

On my site I would really prefer not to show this postings on the "unanswered qustion" list, as they are not really questions.

The idea is to use a certain tag for this question (e.g. "publication" or "article"). Questions with this tag then wouldn´t show up in the "unanswered qustion" list.

How could this be done or is there a better solution? Would it be difficult to program a small plugin, where you just define the list of tags to exclude? Anyone interested in developing such a plugin?
by
It smells like you are actually looking for a new kind of post type rather than QUESTIONS tagged with a particular tag. In fact, I wonder if you're actually looking for a Blog plugin (particularly based on the "publication" or "article" tags you mentioned)
by
I thought a new kind of post would be such a huge change and not easy to implement in the q2a structure without changing the core.

Also I really like the structure and the voting system, and that people can comment and add answers to publications (if not wanted they could be closed).
that´s why I thought about the tag solution, which would not need data structure changes...
by
Good idea. But... there may be a little unreasonable to use tag. I want to a little research this feature.

2 Answers

+5 votes
by
selected by
 
Best answer
Based on a "git pull" comment you've made I have to assume you're a developer. You make a good point on not altering the DB structure. Anyway, you could just add new tables and that won't interfere with the core at all. You can even display these posts in a separate page (page plugin). However, you'd have to implement the voting system on your own (that's a lot of work).
 
If you try to filter out questions tagged with a particular tag from questions lists you'll have to modify some queries, which are part of the core. So you will be modifiying the core in this case. You'll also need to create a page plugin in this case that would list the questions you're leaving out in the first queries.
 
A variation to filter out questions without changing the core would be to filter them out after performing the query in order to avoid changing the core but you'll end up with awkward question counts in each page. In this approach you would be actually using questions posts so the voting feature would be present for them and you can almost reuse the presentation logic from the core in your plugin (you will still have to create a page plugin for displaying this particular questions).
 
The last scenario I've seen someone mentioned some time ago, which is a variation of the first one and I don't find any benefit at all of it, is adding a new post type and store it in the ^posts table. It shouldn't interefer with the core as the core filters them based on the type and queries which use this kind of WHERE clauses field like 'Q%'. So you could try to add new posts there. But again, although you would keep the foreign keys to the table holiding the votes you still have to apply the voting logic to it. This scenario was actually suggested based on a question that dind't require voting on the new post types.
 
Conclusion: try to flexibilize the requirements (remove voting and go for the first or fourth approach), modify the core (and go for the second approach) or accept question lists might/will loose items when displaying them (this is the third approach). I can not think of anything else right now but should be enough to get you started :)
 
Edit: Core hack approach
Look for this line in qa_db_unanswered_qs_selectspec function in qa-include/db/selects.php
 
$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
"type=$ AND ".$bysql.
" AND closedbyid IS NULL ORDER BY ^posts.created DESC LIMIT #,#) y ON ^posts.postid=y.postid";
 
Change it with this line:
 
$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
"type=$ AND ".$bysql.
" AND closedbyid IS NULL AND NOT FIND_IN_SET('publication', tags) ORDER BY ^posts.created DESC LIMIT #,#) y ON ^posts.postid=y.postid";
 
Alternatively, you could join twice to reach ^words but I guess the double join will be worse than the string search. Alternatively, you could manually from the DB fetch the id for the word 'publication' and just join with ^posttags using that ID. However, when the ID changes, maybe after reindexing you'll have to manually get the ID again and force it in the query.

 

by
I would consider myself more an advanced user or admin, but not a developer. I really appreciate the community and try to support q2a by sponsoring development of plugins.


Thanks a lot for your answer and comments:
"You'll also need to create a page plugin in this case that would list the questions you're leaving out in the first queries."

I hope with the tag approach this is not necessary, because we could use the normal tag pages for displaying the left out questions.


"... filter them out after performing the query...but you'll end up with awkward question counts in each page"
Probably depends on the number of publications or articles that are filtered out and might be acceptable. Maybe there is also a way to fix it with some additional javascript/ajax calls in the background (no idea how...)

A fith approach might be:
Setting a question in the database as "answered", although it doesn´t have an answer. Probably by changing the column "acount" of a question to 1 ?
Would this have negativ impacts on the statistics or other q2a functionality?
by
I have to confess I've read your question a bit quickly and missed the fact that you don't want to display them in the "unanswered question". I assumed you didn't want to display them in any other question list (eg: All Activity, Q&A, HOT, etc).

This means you don't actually need a page plugin as you're using the existent ones. Although most options remain the same, this opens the game a little bit. Particularly, the "hack the core" alternative as you would only have to modify a single query. You can't change it from a plugin. And now your "acount" question makes sense to me.

You want to avoid changing data in the core that way. But you can always change the select statements that fetch the data without messing with actual data. I've updated my answer to reflect the simple change.
by
Thanks a lot pupi1985 for the core hack approach. It works great!!
Changing just one line and the problem is solved :-)

The other solutions would have been a lot more work and so I prefer to take a note for the next update of the core.
by
This core hack is so beautiful. Actually it allows a Q2A site to be used for different purposes or even allows some users to filter out non-interesting questions (assuming all are having some common tag).
+1 vote
by

This may not be the answer, but I would report as one example (approach).

Basic architecture:

Divide questions and articles with category

Features of available Q2A cores

  • Change $QA_CONST_PATH_MAP in qa-config.php
      e.g.
      $QA_CONST_PATH_MAP=array(
        //'questions' => 'topics',
        'categories' => 'sections',
        'users' => 'contributors',
        'user' => 'contributor',
        'ask' => 'post',
      );
  • Customize language with qa-lang/custom/qa-lang-*.php
      e.g.
      'nav_ask' => 'Ask',  ===> 'nav_ask' => 'Post',
How to exclude articles from question list
 
Tag can be omitted, but category can be made mandatory with category option of Q2A core.
  1. Remove links of the default question list on main menu,
  2. Add links to each (Questions and Articles) category

How to exclude articles from unanswered question list

Q2A has feature to filter unanswered list with category. However, this is turned off by default in qa-config.php.

Before:
define('QA_ALLOW_UNINDEXED_QUERIES', false);  // <=== Default

After:
define('QA_ALLOW_UNINDEXED_QUERIES', true);

By this operation, you can filter unanswered list with category.

e.g.

http://yoursite/unanswered    <<< All unanswered questions

http://yoursite/unanswered/qsection    <<< Unanswered questions filtered "qsection" category

Addition

Of course, we will need fine tuning other than the above. However, we will be able to realize article feature with fewer changing core.

...