Nucleus Plugin: NP_Counter2
| Current Version: | 0.4 |
|---|---|
| Code: | counter2/ |
| Demo: | http://budts.be/weblog/ and http://www.officialsm.net/blog/ |
| Forum Thread: | http://forum.nucleuscms.org/viewtopic.php?t=3558 |
Using the plugin
With this plugin you can add a textual or graphical counter to your weblog, which count’s the number of visitors, instead of the number of hits. It does this by starting a phpsession when the visitor views the first page, and it stores the value of the counter at that moment for the visitor so that he sees the same value for the counter on every page. It also detects the most common bots and spiders, like google, to prevent them from being counted. It stores the value of the counter as a blogoption so that every blog in your Nucleus installation has its own counter.
To display the (textual) counter add the skinvar <%Counter2%> somewhere in your skin (you can also use <%Counter2(textual)%>). If you prefer a graphical counter you can use <%Counter2(graphical)%> (don’t forget to upload the images as well as decribed in the Installation) Since version 0.4 NP_Counter2 also includes a ‘feedcounter’ to count how many times your feeds where downloaded. This counter doesn’t use a phpsession. To count, add in every skin of your feeds (rss1, rss2, atom,...) somewhere <%Counter2(feeds,nodisplay)%>, this will count everytime your feed is downloaded. To show the value of this ‘feedcounter’ add somewhere in the skin of your blog <%Counter2(feeds,textual,nocount)%> (or <%Counter2(feeds,graphical,nocount)%> for a graphical version)
Installation
Due to the use of a blogoption this plugin requires Nucleus v2.20 or higher.
- Copy the Code and paste it in a file called
NP_Counter2.php, upload it to the plugins folder of your Nucleus installation and install. - Add the following line to the top of your Nucleus
index.php(or yourconfig.php). If you use NP_WIE you should have done this already. (if you only plan to use the feedcounter this is not necessary, since the feedcounter doesn’t use a phpsession)session_start();
- If you want to use a graphical counter, create a folder called
counter2(lowercase!) in your plugins directory. Create 10 images (for every digit one) and call them0.png,1.png,2.png, and so on and put them in thecounter2directory (or download my 10 (ugly
) digit images: counter2.tar ).
To upgrade to version 0.3 (or higher) when you are using version 0.1 or 0.2, you should first uninstall the previous version (before you do this ‘back-up’ the value of your counter, because this is also deleted!)
Once again (sorry!) when you are using version 0.3 and want to upgrade to 0.4, you should first uninstall the plugin (don’t forget to backup!)
Options
- The plugin adds one option to every blog in your Nucleus installation:
- Value of your counter (0): This is the current value of your counter (of the blog you selected).
- And has one plugin option:
- Value of you feedcounter (0): This is the current value of your feedcounter.
SkinVar options
The skinvar has three options:
- counterType = visits|feeds : visits selects the normal counter, feeds selects the feedcounter
- counterMode = textual|graphical|nodisplay : textual show a textual counter, graphical shows a graphical counter, nodisplay permits the counter from being displayed
- counterUpdate = count|nocount : count counts the hit, nocount permits the counter from counting the hit
Some examples:
<%Counter2(visits,textual)%> <%Counter2(visits,graphical,nocount)%> <%Counter2(feeds,textual,nocount)%> <%Counter2(feeds,nodisplay)%>
Screenshots
Get the plugin
You can get the code of the plugin HERE
Bugs
- Sometimes counter displays ‘1’ instead of actual counter value. Maybe the detection of a session doesn’t work always? (instead of the sessionvar not set it has an initial value of 0 so the counter thinks there is an active session, resulting in counter value 1 (although this should be saved then in the db which is not)
- Sometimes the counter seems to reset itself.. whoops. (Only had it twice...)
Version History
- 2004-04-22: v0.1: Initial Version
- 2004-04-23: v0.2: Added bot detection
- 2004-04-25: v0.3: The value of the counter is now stored as a blogoption so that every blog has its own counter
- 2004-05-11: v0.4: Added a counter for feeds, Added ‘nodisplay’ to not display a counter (only count), Added some more bots (7), Added ‘nocount’ option
Ideas for a future version
- extra bots/spiders:
- BlogPulse (ISSpider-3.0)
- kinjabot/1.0 beta (http://www.kinja.com/help/)
- timboBot/0.9 http://www.breakingblogs.com/timbo_bot.html
- The World as a Blog :: http://brainoff.com/geoblog/
- blogsnowbot http://www.blogsnow.com/bot.html
- Pompos/1.3 http://dir.com/pompos.html
- Wget/1.8.2
- ZoekyBot/1.1 (http://www.zoeky.nl/bot.php)
- hitcounter today
- phpDoc comments

