cosmocode / dokuwiki-plugin-top

Simple DokuWiki plugin to count page accesses and display the most popular pages
1 stars 3 forks source link

Request: option to limit results only to a particular namespace #10

Open shallimus opened 7 years ago

shallimus commented 7 years ago

I wanted to display only the top pages from a particular namespace (e.g. "procedures"), which I had expected to find as an available option in the top plugin, but perhaps not as many people want this feature as I imagine!

I managed to get this working by adding the following to syntax.php of the 2016-01-13 version:

47c47
<             $options = array('lang' => null, 'month' => null, 'tag' => 'ul', 'score' => 'false' );
---
>             $options = array('lang' => null, 'month' => null, 'tag' => 'ul', 'score' => 'false', 'namespace' => null);
94a95,98
>
>             // Hack support for 'only this namespace'
>             if ($data[1]['namespace'] !== null && strpos($item['page'], $data[1]['namespace']) === false) continue;
>

It's probably not ideal code, since if the argument to namespace is "procedures", this will also include pages from the namespace other:procedures and yet:more:procedures, but it's enough to be useful to me at the moment.

I regret that I am not in a position to submit this as a GitHub change - and as I mention above, I don't think it is good enough quality as it is - but hopefully this diff will be useful to someone.

FosseWay commented 7 years ago

I've proposed #12, which includes and extends this functionality so that a space-separated whitelist and blacklist may be specified as a parameter for each instance of top.