MTVote

It's been a while since I wrote just a plain plugin, and this doesn't really qualify as one. But it's close. I was inspired by a thread in the MT Support Forums today, and figured it was a good excuse to play with some of the new features in MT 2.6.

This is still a very preliminary version. I am far from finished. But it works, and there's enough code there for people to play around with in their blogs, so I figured I would release what I've got so far and keep working on it.

First, the new tags: MTVoteNumber, MTVoteAverage, and MTTotalValue. MTVoteNumber gives you the number of votes submitted. MTVoteAverage gives you the average vote value. MTTotalValue gives you the total value of all the votes.

Now, to cast a vote, use mt-vote.cgi. You'll have to setup a form or a link to a URL using the following fields: __mode, entry_id, and value. Set __mode to vote to cast the vote. The entry_id field contains the entry id on which to cast the vote, at value's value. For example, to cast a vote of 7 on entry 157, use the following URL:

http://www.yourdomain.com/mt-path/mt-vote.cgi
?__mode=vote
&entry_id=157
&value=7

So, to use this plugin, download either vote.tar.gz or vote.zip, unpack it, and place mt-vote.cgi in your base MT directory, Vote.pm in the lib/MT/App/ directory, and votes.pl in the plugins/ directory.

Planned for future versions:

  • Threshold Actions (see thread linked above)
  • Spiffy configuration interface
  • Whatever else I come up with or other people suggest/request

Update (2003-03-06 16:13):

  • Added a new container tag, MTVotes, that contains entries sorted by highest average vote. You can use any of the standard MTEntries tags within it, including the MTVote tags. It takes two arguments: lastn which defaults to 1 and current_blog_only which when set to 1 (it defaults to 0) will limit the entries returned to only those in the current blog.
  • Added an argument to MTVoteAverage: places determines the number of decimal places to allow in the average, defaults to 0.

12 TrackBacks

Vote from MT Plugin Directory on March 10, 2003 1:35 AM

TITLE: Vote URL: http://mt-plugins.org/archives/entry/vote.php IP: 66.246.57.2 BLOG NAME: MT Plugin Directory DATE: 03/10/2003 01:35:59 AM Read More

Vote something I bleive... Read More

Add Voting to your posts from Fembat.Net [Journal] on May 19, 2003 11:15 AM

I've decided to have a play with MTVote, another plugin brought to you by David Raynes In the interests of... Read More

Add Voting to your posts from Fembat.Net [Journal] on May 19, 2003 11:17 AM

I've decided to have a play with MTVote, another plugin brought to you by David Raynes In the interests of... Read More

Add Voting to your posts from Fembat.Net [Journal] on May 19, 2003 11:22 AM

I've decided to have a play with MTVote, another plugin brought to you by David Raynes In the interests of... Read More

Rate me! from TotalRaptor.com on January 17, 2004 10:42 PM

I added a post rating feature today. Each post can now be rated on a scale of 1 (low) to 5 (high) by simply clicking the appropriate button at the bottom of a post. Next week, I'm going to add... Read More

Who and what helped me in my quest for the best look, feel and experience. (I'm talking about this site, not Viagra!) Read More

Rate me! from TotalRaptor.com on March 23, 2004 11:34 AM

I added a post rating feature today. Each post can now be rated on a scale of 1 (low) to 5 (high) by simply clicking the appropriate button at the bottom of a post. Next week, I'm going to add... Read More

sub zero from mizzenblog on July 9, 2004 9:34 AM

My town is typically the coldest in my region in winter, and the hottest in summer. We're right in the middle of winter now, and temperatures have been getting down to -5° (for any Americans out there, that's 23° Fahrenheit... Read More

給自己的MT安裝一個投票功能,也是很有意思的改造。具體的方法我簡單的介紹如下: ... Read More

給自己的MT安裝一個投票功能,也是很有意思的改造。具體的方法我簡單的介紹如下: ... Read More

It is reasonable to suggest that a large chunk of blogs are just like forums with one difference: on a blog, the ability to create a new thread is limited to the authors of the blog. Why then has blogging... Read More

32 Comments

Perhaps an automatic redirect back to the page the vote was posted from? Rather than having to hit the back button on the "vote posted" page.

Very nifty. =)

I would like to see your script in action! Is that possible?

Heads up: you left 'mt-vote.cgi' out of the tarball version ...

Whoops. :)

All fixed. Thanks for the heads up.

THis address was on my error log , how come ?

THis address was on my error log , how come ?

You can see it in action here: http://www.pocketpcstuff.com/TodayThemes/

I am using it with graphic input.

is it possible to show the top 5 or so rated posts, with their average vote and number of votes. I've tried to do it but come up with a load of garble and zero rated posts.

Any help would be really really appreciated!

"is it possible to show the top 5 or so rated posts, with their average vote and number of votes"
This would be a great additional feature.

I've been using this plugin on my site for a few months now, and I absolutely love it. The only problem that I have is that sometimes when I'm sorting the posts in highest to lowest order, a stray post appears where it shouldn't (normally voted lower, and being displayed higher). I've fiddled with the sql tables with reasonable success, but there are always a few which get displayed out of order.

Are there any plans for a more user friendly interface in which votes can be changed?

Nukie,

I saw on your site that you managed to modify the voting script so it displays a HTML type of message when you vote and it returns you to the previous page automatically.

How did you do that? Can you let me know? I did not find your e-mail address - mine is: peter.osterversnik@ojster.com

Thank you in advance!

Best regards,
Peter

The onyl changes that were made were to the vote.pm file. Almost at the bottom the line that read:

"Vote posted";

Was changed to:

sprintf "***snip***", $entry_id;

The snips are where I had the rest of my page code in there. As far as I can work out:
- it all has to be on the one line (yes it gets big but do try to live with it).
- everywhere in your code you have a ", there needs to be a \ in front of it.
- wherever you want the id number of the post to be displayed, whack a %06d in there. I use this for the auto redirect.
- the only downside i can see with this hack is that it has to be the same page for all the mt blogs you use the vote script on.

If anyone finds a better way to do it, please do give me a yell :)

The only changes that were made were to the vote.pm file. Almost at the bottom the line that read:

"Vote posted";

Was changed to:

sprintf "***snip***", $entry_id;

The snips are where I had the rest of my page code in there. As far as I can work out:
- it all has to be on the one line (yes it gets big but do try to live with it).
- everywhere in your code you have a ", there needs to be a \ in front of it.
- wherever you want the id number of the post to be displayed, whack a %06d in there. I use this for the auto redirect.
- the only downside i can see with this hack is that it has to be the same page for all the mt blogs you use the vote script on.

If anyone finds a better way to do it, please do give me a yell :)

How can I get one of these for my site?

MT Error log coming from address

What exactly goes in the "***snip***"?

Is it possible to set it so people can't vote over and over again on the same entry? i.e some sort of cookie system which only allows one vote per entry within a time period.

I am getting the following error. Some times when I try to save the entry, and other times when I try to submit a vote.

Can't call method "blog_id" without a package or object reference at plugins/votes.pl line 48.

Just curious. Where does this plugin store the vote data? In the database? I use Berkely DB, will I be able to delete the vote data at a later time without damaging the rest of my database files?

if you want to automatically go back to the page that the vote came from change the last line of Vote.pm from

"vote posted";

to

"go back\n\nVote Taken";

or somthing simular

well if i had used preview the line to change it to would have looked like this

"<html><head><title>go back</title>\n<meta HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=".$ENV{"HTTP_REFERER"} . "\">\n</head><body>Vote Taken</body></html>";

For some reason I'm suddenly (As in it used to work before) an error that goes like this:

"Illegal division by zero at lib/MT/App/Vote.pm line 45"

I tried uploading Vote.pm and MTVote.cgi and the .pl file, can someone help me? It would really be appreciated.

has mariko's issue been solved? i'm assuming it is due to an upgrade of some kind? any ideas?

Is MTTotalValue effective?
Isn't MTVoteTotalValue right?

Is MTTotalValue effective?
Isn't MTVoteTotalValue right?

Vacuity is using the plugin now also. You can vote on movies on the page. Thank you very much, this was what i'd be looking for. though an IP-throttle functionality would be great.

BTW i just figured out how to go back to the original entry after voting. replace:

"vote posted";

with:

"Redirect\n\nVote Taken";

but i'm not sure wether it works with all browsers. for IE it works. but the entry doesn't show the casted vote until you refresh the page again manually.

I saw the plug-in in action at
http://www.pocketpcstuff.com/TodayThemes/
and I like the graphic input.
How works the javascript?
Where I can find it?
It would be great if there will be a graphic output....

might wanna add "change permissions on mt-vote.cgi" to the doc @ the wiki... morons like me stay up too late and frget....wasting time. Also... what are other "modes" than vote? awesome plugin.

how to sort "top5" in not by Average, but by Total Value, or by Number of Votes?

David,

your plugin worked great for almost two weeks - now it has stopped working without an obvious reason saying.

Can't call method "created_on" without a package or object reference at /htdocs/mt/plugins/votes.pl line 50.

This is the code we use:


Most popular
" add_onclick="1"
title="">...


Any help appreciated!

Thanks in advance!

Leave a comment

About Me

I am a software developer for Six Apart living outside of Baltimore, MD. I have written a number of plugins for Movable Type, including the award winning MultiBlog, which has (as of MT 4) been integrated into the base application....
More...

Recent Entries

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

  • Feedburner Widget 0.3

    At this point, I am really tempted to drop the ‘Widget’ from the name of the plugin, since it is doing so much more...

  • Feedburner Widget 0.2

    So I finally got around to updating the FeedburnerWidget plugin for MT 4.1 (since I finally got around to upgrading my install to MT 4.1)....

Close