Wiki source code of Enable Statistics for a Subwiki
Last modified by Eleni Cojocariu on 2026/09/16 11:37
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Storage of statistics is decided per wiki by the ##statistics## field of that wiki's ##XWiki.XWikiPreferences## object, and no administration screen creates that field. Adding it by hand is the only way to store statistics for one subwiki, and it takes two steps: the field has to exist in the class before it can be set on the object. | ||
| 2 | |||
| 3 | You need administration rights on the subwiki, and the statistics module has to be enabled for the instance, which it is unless ##xwiki.stats## was set to ##0##. See [[Statistics Configuration>>doc:documentation.xs.admin.statistics.WebHome]]. | ||
| 4 | |||
| 5 | 1. On the subwiki, open ##/bin/edit/XWiki/XWikiPreferences?editor=class##. | ||
| 6 | 1. Type ##statistics## in the "Add new property" field, leave the type on "Boolean", and click "Add". The property is added to the class straight away.((( | ||
| 7 | {{image reference="statistics-class-property.png" size="extra" alt="The class editor of XWiki.XWikiPreferences with statistics typed as the name of a new Boolean property"/}} | ||
| 8 | ))) | ||
| 9 | 1. Open ##/bin/edit/XWiki/XWikiPreferences?editor=object##, expand "Objects of type XWiki.XWikiPreferences" (which is when its fields are loaded), set the ##statistics## field at the end of the list to "Yes", and save. | ||
| 10 | 1. The field now reads "Yes", and the subwiki stores statistics from its next page view: the field is read on each request, so nothing has to be restarted, unlike a change in ##xwiki.cfg##. Nothing reads those statistics: their only interface, the [[Statistics Application>>doc:extensions:Extension.Statistics Application.WebHome]], has to be installed separately and is no longer maintained.((( | ||
| 11 | {{image reference="statistics-object-enabled.png" size="extra" alt="The statistics field of the XWikiPreferences object set to Yes in the object editor"/}} | ||
| 12 | ))) |