0

I have set up to display the page-view (hit) counter, using the Drupal 7 core statistics module, following the standard procedure (see, for example, the summary here).

However, (A) only English contents show the counter but none of the other languages on a site, and (B) none of the contents show the counter on another site.

The structure and installed modules in those sites are slightly different. However, as far as the settings (configuration, permission etc) of the statistics module is concerned, they are the same.

What is happening? Where should I look for to investigate?

1 Answer 1

1

I suppose the cause can vary. However, it seems multilingual sites may have additional factors that contribute to make this counter-related stuffs go wrong. Here are a couple of example cases for multilingual sites.

I assume you are using the path-prefix based language negotiation as the high(est) priority. In your case (A), is the English the default language and no path-prefix is defined for English? In your case (B), are the path-prefixes defined for all the enabled languages, including the default language? In those cases, it is suspicious some module(s) that use i18n are causing a trouble.

First, check the database table node_counter. If a node has a non-zero totalcount, and if you don't see the page-view counter when you view the node, then it is likely to be down to either the permission or your theme, which may not show the counter in the first place.

If the totalcount column has zero count, despite you (preferably as a non-authenticated user) have viewed the node (and have flushed all caches), then the statistics module is not working, either due to its own failure or other module(s) fail to access the statistics module.

Have a look at "Recent log messages" /admin/reports/dblog. If you see (probably plenty of) "page not found" for modules/statistics/statistics.php, then the latter is the case, or at least is contributing.

In that case,

  1. Confirm modules/statistics/statistics.php does exist, and the file permission is set to be readable to any one, as well as all the parent directory permissions are set to be readable and executable to any one.
  2. In the table of "Recent log messages" /admin/reports/dblog, click the links (for TYPE: page not found) modules/statistics/statistics.php in the Message column. What do you see? Does the LOCATION include the language prefix (like /fr/)?
  3. If that is the case, your module(s) try to access the non-existing page like fr/modules/statistics/statistics.php instead of the correct path without the language prefix. Best figure out which module is causing the trouble and fix the module. If that is not practical, alternatively you can control the path at the server level: read the answer to Why so many “page not found” for statistics.php?.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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