Mangoblog plugin: viewCount v1.2.5

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.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.coldfusiondeveloper.nl/viewCount/viewCount-plugin-Mangoblog-v1.2.5.zip
Then, you need to activate it by pressing the link 'Activate' next to the plugin.

The settings

viewCount admin screenYou can control the plugin in 3 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?
  • 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" />

Count it, but don't show it?

You can also decide not to show the counter, but to have the counter count it anyway. You then need to replace the tag <mango:Event name="beforePostContentEnd" /> with <mango:Event name="updateViewCount" />. In this case, do watch out that no other plugin is using the beforePostContentEnd event!

The code itself

Links

When you're using the plugin, and/or have any questions, leave me a comment! I'd like it ;-)

Posted by Paul Klinkenberg on 12/31/2009 at 12:54 PM | Categories: jQuery + Javascript - CFML - MangoBlog - | View count: 660

13 Comments

John Sieber

John Sieber wrote on 01/23/10 11:42 PM

I was able to successfully download and install the plugin on my Mango MySql installation but I'm unable to access the settings in my admin. The option for ViewCount is at the top of my Settings page but there are no options in the content area. Any ideas?
philipholmes

philipholmes wrote on 01/24/10 6:41 AM

I was able to download and install the but I not successfully so I creat a problem -------------------------------
Paul Klinkenberg

Paul Klinkenberg wrote on 01/24/10 1:55 PM

@John Sieber, I just released version 1.2.1, based on your input. Would you please check that one out and let me know if the admin works? http://www.coldfusiondeveloper.nl/viewCount/viewCount-plugin-Mangoblog-v1.2.1.zip

@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
John Sieber

John Sieber wrote on 01/24/10 8:38 PM

@Paul Klinkenberg, I tried the new version on my dev environment as well as my live blog and still had the same behavior. The plugin installs without error but when I click the link to configure the plugin no options show up in the content area of the admin. No errors occur, but I assume that there should be options in the settings when you choose to configure. ViewCount does show up in the header of my settings page in the admin. My live server is running Railo 3.1 and my development setup is using Railo Express 3.1.2.001.
Paul Klinkenberg

Paul Klinkenberg wrote on 01/25/10 12:35 PM

John, I can see the error which occured. I didn't take into account that you're using a prefix for the database tables.
If you would: http://www.coldfusiondeveloper.nl/viewCount/viewCount-plugin-Mangoblog-v1.2.2.zip
Thanks!
John Sieber

John Sieber wrote on 01/26/10 3:52 AM

Paul, this version works great. I will leave it activated and let you know if I see any issues. Cool plugin, nice job!
John Sieber

John Sieber wrote on 01/28/10 5:01 AM

Paul, I've been running the plugin for a few days and it is not updating the counts. Could it be related to the table prefixes? One other issue that I noticed, if I try to sort the results table in the admin by the ViewCount heading the page goes blank.
Paul Klinkenberg

Paul Klinkenberg wrote on 01/28/10 11:52 AM

Hi John, Thanks for your continued debugging ;-)
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
John Sieber

John Sieber wrote on 01/28/10 4:35 PM

Hi Paul,
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
John Sieber

John Sieber wrote on 01/29/10 6:35 AM

Everything is working good now. The adding of the beforepostcontentend tag to my theme allowed the counting to start and the sort on viewcount works correctly as well. Thanks!
PO Chassay

PO Chassay wrote on 02/13/10 12:28 PM

Thanks for the plugins. Everything works properly with Railo 3.1.2.001 final, MySQl, on a Linux Box.
John Gag

John Gag wrote on 02/16/10 7:31 PM

Awesome! I was thinking of making this type of plugin but it looks like you did a great job. Thanks a lot!
Mark Aplet

Mark Aplet wrote on 02/18/10 6:26 PM

Great plugin. If you plan to add additional features in the future might I make a few suggestions.

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. :)

Write your comment




Leave this field empty: