Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+8 votes
97 views
in Q2A Core by
by
What do you mean by "point table?" A tabular display of how many points actions will yield? A list of points the user received? Something else? Where do you want to show it?
by
I want to show it on a specific page so that everyone can see it.

1 Answer

+1 vote
by
edited by

Assuming that by "it" you mean a list of the actions and the points rewarded for them you'd have to write a custom page module. The point values are stored in the database table qa_options and can be retrieved with a query like this:

SELECT title,content
FROM qa_options
WHERE title LIKE 'points_%';

The description text of the options is stored in the file qa-include/lang/qa-lang-options.php and can be retrieved like this:

qa_lang('options/OPTION_TITLE');

For example, on an English language Q2A site a code snippet

$opt_title = 'points_a_selected';
$opt_text  = qa_lang("options/${opt_title}");

will put the following string (including the trailing colon) in the variable $opt_text:

Having your answer selected as the best:

To show a points table you'd iterate over the values returned by the database query, look up the corresponding description for each option title, and then output description and points.

$query = '...';
$points_options = qa_db_read_all_assoc(qa_db_query_sub($query));
foreach ($points_options as $opt) {
  $descr  = qa_lang("options/${opt['title']}");
  $points = $opt['content'];
  // output $descr and $points however you see fit
}


If you just want a simple table to display the points (without automatically filling in the values from the backend) you could create a page via Administration center - Pages and set a manually crafted HTML table as the content for that page. The basic structure of such a table would look like this:

<table>
  <tr>
    <td>Foo points:</td>
    <td>23</td>
  </tr>
  <tr>
    <td>Bar points:</td>
    <td>42</td>
  </tr>
  ...
</table>

or, in more compact notation, like this:

<table>
  <tr><td>Foo points:</td><td>23</td></tr>
  <tr><td>Bar points:</td><td>42</td></tr>
  ...
</table>

Beware, though, that you will have to update that table manually whenever you make changes to your points system.

by
I don't understand coding very much. Tell me in a simple way how can I create a page like this? Step by step...
by
edited by
+1
There is no simpler way if you want to create a custom page that shows the actual data from the backend. You need to write a custom page module for that, and to do so you need at least some level of knowledge of the technologies involved (namely PHP, MySQL, HTML, and CSS). Alternatively you need to hire someone with that knowledge.

An alternative approach would be to manually craft a static HTML table with the points information and put that as the content of a page you add via "Administration center > Pages". However, in this case changes to the points are not automatically reflected in the points page. You need to update it manually every time.
by
In your second method I want to show the points table via hyml. In that case write an html code so that we can use that code. And can change as needed.
by
See updated answer.
...