Fortune Widget 0.3
[ This is an old version - Please see Fortune Widget 0.4 or the Fortune Widget project page]
My very first widget for the Wordpress2 “widgets” plugin. It’s very simple, in that it uses php-fortune to display a fortune from fortune files, which you can either copy into place or point towards ones installed on your system. Note: It comes with “calvin” (I.E. Calvin and Hobbes”) fortune file…
Requirements:
Some fortune files (I’ll post later where to look if you don’t know where to go for these).
Wordpress 2.1.x + Automatix Widgets or Wordpress 2.2.x or newer with modifications
Popularity: 13% [?]


June 4th, 2007 at 7:55 pm
How do I create one of those fortune files?
June 6th, 2007 at 6:26 am
exactly… how to costumize???
June 20th, 2007 at 7:03 am
[...] I do apologize to the couple of people who have asked on my posting of the Fortune Widget on how to create fortune files. I hope to have a post about that soon, since this is kind of an [...]
July 10th, 2007 at 9:33 pm
[...] these steps you should be able to create your own fortune files, which can be used with the Fortune Widget I created for Wordpress. This does get a little tricky for Windows users, as the applications [...]
July 10th, 2007 at 9:37 pm
leander: The customizations are simply the ability to set a title for the widget block, and to select which fortune out of the fortune directory should be used. The issue that I had with other fortune widgets that were out there, were the fact that none of them included the fortune reading php script, and none of them had an easy way of updating which fortune file to use (in most cases you have to edit the script.php file by hand).
May 27th, 2008 at 11:42 pm
[...] I’m trying to be somewhat official with my fortune widget by adding it to the wp-plugins database and committing the code to the svn server. So far I [...]
September 10th, 2008 at 4:16 pm
I copied over a fortune cookie I made and I can’t seem to select it from the widget options.. It also doesn’t see the “cavin” cookie that came with the plugin.. Any ideas?
September 11th, 2008 at 12:30 am
Just a heads up that things have been pretty busy in my life as of late. Probably within the next couple of days I can look into what is going on. I just wanted to make sure you know that I’m not ignoring you.
Until then, without looking at the plugin because it has been a while, the first think I would look at is make sure that you have fortune index and fortune file located in the fortunes directory under [BLOG]/wp-content/plugins/fortune. That is the location the script is going to look for these files. Additionally for it to work correctly, it MUST have both the index and the dat file (I.E. for calvin, the files are “calvin” and “calvin.dat”). Definitely let me know if this doesn’t help you, otherwise, as I mentioned, I will be looking at what might be going on in the next couple of days.
September 11th, 2008 at 4:35 pm
Actually, the plugin wants them in wp-content/plugins/widgets/fortune (at least, the version I downloaded from wordpress.org does). I put both calvin and my own cookie there and it lets me choose them now in the widget config thing, but it displays this error when I view the page: “Unable to find fortune file swadsall,” where swadsall is the fortune cookie I made It does the same thing with calvin. Both the index and the .dat file are there.
September 15th, 2008 at 9:16 pm
Well, first of all I have to apologize because I didn’t realize how behind I was in regards to this being updated for the widgets plugin being integrated into Wordpress. I, out of a sleep deprived state, must have changed it to work and never updated the plugin for everyone else. That being said, the change I made was to move the fortune directory to wp-content/plugins. Both widget_fortune() and widget_fortune_control() both use a $baseFortunesDir, which “should” be identical. IF they are both identical, double check the permissions of the files such that the web server can read the appropriately. The next possible thing, is to make sure that the fortune.php script is in the same directory, as this is needed to actually read the fortune file. Unfortunately, out of my continued sleep deprived state, I didn’t write a very good validation / error message routine for that (this actually may be the most likely scenario).
I do plan, after seeing all this, that I plan to write in some improvements such as a single variable for the location with a corrected path, and better output to indicate that everything is in order. Let me know what you find out, because I’d really like to get you working…
October 5th, 2008 at 7:26 pm
Hey! I finally got around to playing some more and after I copied the fortune.php file into wp-content/widgets/fortune/ it worked fine! Thanks for the help, dude!
October 7th, 2008 at 5:54 am
Not a problem! I’m just glad that it worked out for you.
December 23rd, 2008 at 7:05 am
I’ve done some work on a similar but unrelated project. It is a fortune plugin for the main page.
http://mickdakota.com/wordpress-fortune-plugin
It uses the fortunemod.com API on the net so doesn’t require any local fortune files or parsing scripts. The downside is that you can’t create your own cookies. The upside is that you can just set it and forget it and get immediate access to a huge collection of quotes from 50-60 of the top fortune databases.
As it is targeted at the content region you also are not limited to your sidebar width as you would typically be with a widget, so you get much better display formatting.
December 24th, 2008 at 6:21 pm
It’s good to see a variety of plugins available, especially with quotes, since quotes can be quite difficult to come by if you don’t already run a unix/linux system or have the technical know how to create quotes. The only downfall that I would raise about off-loaded storage, or any kind, the performance hit when the Wordpress has to contact other websites / offsite servers to derive a given page. It might be worth while to recommend a page caching plugin in conjunction with wordpress-fortune-plugin…
January 31st, 2009 at 2:18 pm
[...] Fortune Widget – Fortune widget (Random Quotes), with some simple customizations and easy install. [...]