Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
253 views
in Q2A Core by

I recently installed this package and noticed that there was no "views" shown in my version.  After some debugging, I determined that the "show_view_counts" option was NULL in my qa_options table.

This raises 2 points:

  • There doesn't seem to be any GUI to turn this on / off.  Maybe I'm just missing it?
  • The variable "show_view_counts" seems to be mising $fixed_defaults array in qa-include/qa-app-options.php

Am I right about this?

Thanks.

1 Answer

+3 votes
by

I found it strange also that the view count was missing.  But if you look on line 292 of qa-page-admin.php, you find:

        case 'lists':
            $subtitle='admin/lists_title';
            
            $showoptions=array('page_size_home', 'page_size_activity', 'page_size_qs', 'page_size_hot_qs', 'page_size_una_qs');
            
            if (qa_opt('do_count_q_views'))
                $showoptions[]='show_view_counts';
              


And lo and behold, go to admin/lists, and there is the option.

by
Good to know.  I still think the setting is missing in the initial config though.  I noticed that in the DB, the value was initially null.  I manually updated it to 1 and it started working as expected.  Now I notice that the config GUI toggles the value between 0 and 1 but it's still never null.

Anyway, thanks for the tip.
by
That's just how the settings work.  I doubt there was a database entry at all.  When you call qa_opt(), it returns a NULL value when the setting doesn't exist (unless there is a default set, which there isn't in this case).  For PHP tests, NULL is effectively the same as 0, so this is fine.  If you do a test:

if(qa_opt('show_view_counts')

you'll get false either way.  If you check the checkbox, it will be saved as a 1 in the database, and then the above test will return true.  If you uncheck it later, it will be saved as a 0, effectively the same as not having the setting at all.  That's just how the script works.
by
This bug can still be seen in Q2A 1.6 Progress,please remember to fix it.
THX!
...