Wouldn't you like to know how many people have read your blog post? Well, I do like so. In the blog system mangoBlog, which I use for this weblog, this wasn't a default option, and there wasn't a plugin yet to add this.
So, I created a plugin. You will already see the words "view Count: x" underneath this blog text.
What's new in:
See changes in subversion
Version 1.5
Compatibility bug fix for version 1.6 of mangoblog
Version 1.4
Added new admin setting "view count text", so you can now decide what viewcount text you want to show in your website.
Version 1.3
Added new admin setting "show count in weblog?" to optionally hide your view counts.
The viewcounts are now also shown on the Posts overview page! Thanks to Mark Aplet for the tip!
Version 1.2.5
Zipped the outdated version of settingsForm.cfm in 1.2.4. this version fixes that.
Version 1.2.4
Fixed a bug with the latest version of mangoblog, which prevented the plugin from working.
Version 1.2.3
Less database interaction because of caching.
Support for MySQL as well as MSSQL!
Admin-problem resolved for implementations which use a table-prefix with their database tables.
How to use?
Go to your mangoBlog admin > Plugins, and enter the following url to download:
http://www.railodeveloper.com/viewCount/viewCount-plugin-Mangoblog-v1.5.zip
Then, you need to activate it by pressing the link 'Activate' next to the plugin.
The settings
You can control the plugin in 3 4 5 ways, reached from the Settings page in your mangoBlog admin.
- "Count views from web spiders/crawlers?" Default: No.
These are page requests done by search engines like Google, to index your website. To be honest, these aren't real views, but on the other hand, it IS a request. - "" Default: 2 hours.
ViewCount remembers the time and IP address for each counted view. After how many hours should we consider a page view from the same IP to the same post a new view? - "Show viewCount in website?"
In case you want to hide the view count from the public. - "Text to show"
By default, the plugin will show "View count: 123". Here, you can change the text which will be shown.
You can use a placeholder for the viewcount number by adding $viewcount$.
Examples: "viewed $viewcount$ times", "$viewcount$ views", or "| $viewcount$ keer bekeken".
If you leave the $viewcount$ out, then it will be added to the end of the text. And yes, you can add html - You can change the counts yourself.
If you already have your blog for years, and don't want to look like a lonely idiot with no visitors at all, then just start off with a higher number.
Are the counts not working/showing up on your pages?
That will probably have to do with your template/Theme. Check if your post.cfm-template (found in /skins/template-name/) contains a tag <mango:Event name="beforePostContentEnd" />. If not, then just copy and paste this tag into the div at the end of the post, just after the "Posted by ..." text.
Want to show the view count on the index pages as well?
As you can see on my homepage and archive pages, the view count is show for each post. To accomplish this, you need to edit the 2 templates index.cfm and archives.cfm, both in your Theme directory. Just add the following text near the "Posted by ..." line:
<mango:Event name="showViewCount" />
The code itself
- View and download all code from my SVN browser
- Or download the full package
Links
When you're using the plugin, and/or have any questions, leave me a comment! I'd like it ;-)
| Viewed 11170 times
#1 by John Sieber - January 23, 2010 at 11:42 PM
#2 by philipholmes - January 24, 2010 at 6:41 AM
#3 by Paul Klinkenberg - January 24, 2010 at 1:55 PM
@philipholmes Did you have the same problem as John? That the admin screen was just plain white without the settings showing up?
Can you also pelase try this version 1.2.1?
Thanks to both! Paul
#4 by John Sieber - January 24, 2010 at 8:38 PM
#5 by Paul Klinkenberg - January 25, 2010 at 12:35 PM
If you would: http://www.coldfusiondeveloper.nl/viewCount/viewCount-plugin-Mangoblog-v1.2.2.zip
Thanks!
#6 by John Sieber - January 26, 2010 at 3:52 AM
#7 by John Sieber - January 28, 2010 at 5:01 AM
#8 by Paul Klinkenberg - January 28, 2010 at 11:52 AM
Please read "Are the counts not working/showing up on your pages?" in this blog post; you very probably have to edit your template/skin. I also don't see the "view count: x" underneath your blog post, which is a good indicator you need to edit the template (either that, or the plugin is inactive).
The problem with sorting on viewCount has been fixed; that had to do with the table-prefixes. My bad :-/
Thanks, Paul
#9 by John Sieber - January 28, 2010 at 4:35 PM
I will take a look at my theme this weekend and make the necessary changes as well as let you know if that works. Have a good one.
-John
#10 by John Sieber - January 29, 2010 at 6:35 AM
#11 by PO Chassay - February 13, 2010 at 12:28 PM
#12 by John Gag - February 16, 2010 at 7:31 PM
#13 by Mark Aplet - February 18, 2010 at 6:26 PM
1. Ability to turn off count display in the public post.
2. Add column to posts listings to display count, rather than going to the plugins settings.
3. A good alternative here is to make a widget to display view counts on the overview page.
Again. Great plugin and I will definitely use. But would love to see this plugin mature, because I can see it as being one of those "got to have it" plugins that are on my first to install roster. :)
#14 by Paul Klinkenberg - March 11, 2010 at 1:16 AM
Those were great tips! This night I found some time, and tadaa, version 1.3!
Hope you like it :-)
#15 by Snake - May 23, 2010 at 12:24 AM
Plugin was activated, but it could not be setup: Tried to return query result when there was no result
no viewcount appears
post.cfm does have <mango:Event name="beforePostContentEnd" /> in it
If I go to the settings for this plugin and try to edit the viewcount I just get a blank page.
No errors in the logs i'm afraid.
#16 by snake - May 23, 2010 at 12:31 AM
#17 by Brandon moser - August 20, 2010 at 4:25 AM
Thanks for the great plugin.
#18 by Paul Klinkenberg - August 21, 2010 at 1:32 AM
There were some problems with downloading the file, you could try it from this location: http://www.railodeveloper.com/viewCount/viewCount-plugin-Mangoblog-v1.4.zip
Thanks for the compliment :-)
#19 by Paul Klinkenberg - February 26, 2011 at 1:53 AM
#20 by Adam Tuttle - January 5, 2015 at 4:14 AM