Mangoblog plugin: viewCount v1.5 - updated 26 Feb. 2011

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

viewCount admin screenYou 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

Links

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

del.icio.us Digg StumbleUpon Facebook Technorati Fav reddit Google Bookmarks
| Viewed 6901 times
  1. John Sieber

    #1 by John Sieber - januari 23, 2010 at 23:42

    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?
  2. philipholmes

    #2 by philipholmes - januari 24, 2010 at 6:41

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

    #3 by Paul Klinkenberg - januari 24, 2010 at 13:55

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

    #4 by John Sieber - januari 24, 2010 at 20:38

    @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.
  5. Paul Klinkenberg

    #5 by Paul Klinkenberg - januari 25, 2010 at 12:35

    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!
  6. John Sieber

    #6 by John Sieber - januari 26, 2010 at 3:52

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

    #7 by John Sieber - januari 28, 2010 at 5:01

    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.
  8. Paul Klinkenberg

    #8 by Paul Klinkenberg - januari 28, 2010 at 11:52

    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
  9. John Sieber

    #9 by John Sieber - januari 28, 2010 at 16:35

    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
  10. John Sieber

    #10 by John Sieber - januari 29, 2010 at 6:35

    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!
  11. PO Chassay

    #11 by PO Chassay - februari 13, 2010 at 12:28

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

    #12 by John Gag - februari 16, 2010 at 19:31

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

    #13 by Mark Aplet - februari 18, 2010 at 18:26

    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. :)
  14. Paul Klinkenberg

    #14 by Paul Klinkenberg - maart 11, 2010 at 1:16

    Hi Mark,

    Those were great tips! This night I found some time, and tadaa, version 1.3!
    Hope you like it :-)
  15. Snake

    #15 by Snake - mei 23, 2010 at 0:24

    When I activate the plugin it says
    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. snake

    #16 by snake - mei 23, 2010 at 0:31

    nevermind I was using the version downloaded from mangoblog.org which is out of date, works fine with 1.3
  17. Brandon moser

    #17 by Brandon moser - augustus 20, 2010 at 4:25

    Any chance you know how to update the plugin? I'm running 1.2.3 and tried to just install the current Zip file, but no luck. I don't want to lose my current counts, so do I just de-activate then install and re-activate? Any ideas would be great.
    Thanks for the great plugin.
  18. Paul Klinkenberg

    #18 by Paul Klinkenberg - augustus 21, 2010 at 1:32

    Hi Brandon, you can enter the link to the zip file in the Plugins section of the mangoblog admin to update the plugin. But I guess you already know that?
    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. Paul Klinkenberg

    #19 by Paul Klinkenberg - februari 26, 2011 at 1:53

    Hi Viewcount-plugin users, there is a new version available, which fixes a compatibility bug for mangoblog 1.6. Cheers, Paul
  20. Adam Tuttle

    #20 by Adam Tuttle - januari 5, 2015 at 4:14

    Just subscribing to the comments in case there are more updates. :)
(will not be published)
Leave this field empty

denominative-lowborn