Not logged in. · Lost password · Register
Forum: General Discussion Plugins Plugin Wishlist RSS
Count Number of Pages in an Namespace
TedBuckland #1
Member since Dec 2007 · 8 posts
Group memberships: Members
Show profile · Link to this post
Subject: Count Number of Pages in an Namespace
Hi!

I would really appreciate if anyone could write a plugin that counts the number of pages in an namespace. It should be possible to add this information to any desired wiki page. (So I guess this would be a syntax plugin). I think this is a useful feature and  shouldn't be too much work once you know which dokuwiki functions to call, but I have no PHP experience and can't do it myself.

Thanks for your help!
emanuele #2
Member since Aug 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
Hi,

I'm working on something similar.
I found the stats plugin and I found that is not working any more, so I'm trying to rewrite the part needed and adding some functionality.

On my site you can find an on-going version.

Up to now it can show the bests contributors, the total number of pages and (hopefully) the number of pages for a particular namespace...I didn't test this particular case very deeply, but it seems to work... :blush:
TedBuckland #3
Member since Dec 2007 · 8 posts
Group memberships: Members
Show profile · Link to this post
Nice Work! I have not thoroughly tested it, but it seems to work nicely. It was just nice if I could achieve one extra thing:
I would like to subtract 1 from every number of pages in a namespace. (That is because there is always one site that only indexes the other ones)

So if namespace toplevel:lowerlevel contains 3 pages, the plugin should print that there are only two. What do I have to change in the syntax.php file to achieve that?

Thanks in advance!
Scarecrow #4
Member since Dec 2006 · 11 posts
Group memberships: Members
Show profile · Link to this post
To subtract 1 from the output pagenumbers you could always just add a "-1" to the value the $renderer actually prints, like this:
l.86      $renderer->doc .= $this->countAllPages($stat);
add -1:
l.86      $renderer->doc .= $this->countAllPages($stat) -1;
Easy and it works, but pretty bad programming style.

Another (and better) option would be to alter the if statement in the _pages_xhtml_r function that determines whether to count +1 or not. Lets assume all your index files are called "index.txt", then the statement:
l.147             if (is_file($path."/".$file)) {
                  $tmp++;
          }
would look something like that:
            if (is_file($path."/".$file) && $file != "index.txt") {
              $tmp++;
            }

Hope that helps.
Scarecrow
TedBuckland #5
Member since Dec 2007 · 8 posts
Group memberships: Members
Show profile · Link to this post
Yes that works out just fine! Thank you very much for the quick reply!
emanuele #6
Member since Aug 2007 · 4 posts
Group memberships: Members
Show profile · Link to this post
Thank you Scarecrow for the tip.

Just as a remark at the moment the plugin don't consider the pages in "wiki", "talk" and "playground" namespaces.

If I'll find some time and I'll understand better how plugins work, I'll add an "namespace exclude list" to the admin page...
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please note the verification code from the picture into the text field next to it.
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 1.6.4, © 2003-7 by Yves Goergen
Current time: 2008-05-17, 03:17:37 (UTC +02:00)
WikiForumIRCBugsTranslate