Since my last work on a custom combobox went so smooth I decided that it is time to try and build yet another custom plugin for JQuery. This time round I’m building a custom calendar object. Now I know these already exists, but this is mostly an experiment to build more experience in developing for JQuery.
As this plugin will require a bit more work then the combobox I have no idea as to when I can release a first usable version. But as soon as I do I will publish it here
.
It was recently brought to my attention that the WordPress plugin I use for posting images on this website was not working properly anymore, thanks for warning me of this issue. Well not working properly in the sense that images would get opened in the same window, with no options to navigate back to the post.
Initially I thought that this was caused by the plugin I use for this called NextGen Gallery. After all this plugin failed to do its job properly, but unfortunately that was a bit stupid thinking on my part. I should have realised that the plugin stopped working after an upgrade of the WordPress blog powering the website. For some reason the thickbox JQuery extension produced JavaScript exceptions.
I don’t know exactly why it doesn’t work like expected and I don’t really care either. Suffice it to say that changing a small piece of code in the ‘wp-includes/js/thickbox/thickbox.js’ fixed the issue. All I had to do is modify the tb_init function into the following:
function tb_init(domChunk)
{
jQuery(domChunk).bind("click", tb_click);
}
I think it must have been some conflict in the JQuery versions or something, since it used to call the ‘.live‘ method on JQuery. But this was what was causing the exceptions. If anyone knows a more permanent fix for this issue please let me know.
A couple of days back I wrote something about some huge issues I had with the PHP autoloader technology. After reading up some more on the autoloader and some help from the PHP developers I finally tracked down the issue.
As it turns out the autoloader functionality is called when PHP is unable to find the class you are using automatically itself as a last effort. Though that wasn't the issue I encountered. It took me about 3 hours of debugging the function to find out there was a problem with the logic of the autoloader function I wrote myself, doh!
Something with breaking out of a loop to early
. After fixing this issue my autoloader was working beautifully. So I am happy to say that it is possible to write a modular PHP web application after all.
Just a few days ago I posted that I started working on a better looking drop down box to replace the select element on webpages. Today the first version is released under the GPL license. You can download it by visiting the plugin page under Plugins - Custom Combobox.
This first version includes:
Please note: as this is the first release there may still be some bugs in the code, please feel free to contact me if you find any and I will attempt to solve them as quickly as possible.
Since PHP 5.x we are encouraged to develop in a more object oriented way. This is why they developed class support for us
. Now to make our web applications even more modular you might consider putting each class in a seperate PHP file, just like Java and C++ developers have been doing for years now. But here is where it becomes tricky, how does PHP know which files to load automatically.
Of course you could include every single file that you might need manually at the top of your index.php. But what if you don't need every single class every time a page is loaded, do you really want to create that kind of an overhead in loading un-needed files? I didn't, so I started looking into the autoloader functionality of PHP. What this feature does is allow you to scan through files in the predefined include directories and attempts to locate the class.
So what I did was build a simple autoloader function to scan each file in predefined directories to find the classes, and if found to stop. To my surprise this was working rather well. All classes that where needed would automatically get loaded by my little autoloader function. However somehow one particular class was not able to be loaded for some reason. The setup was something simple, something like:
All of the classes loaded beautifully, except for class D. For some reason when I tried using it I got exceptions that class C was undefined. When I added some debugging to find out which files where loaded I did see every file for classes A, B and C being loaded, but the actual classes defined inside where not added to PHP. Somehow I have magically created a black whole in PHP that would include files and then forget to create the class definitions internally. To this day I still haven't figured out why PHP refused to store the actual classes in its memory.
The quick fix I applied was ugly and stupid, just manually load the classes and build a big if statement around them to prevent duplicate declarations using the class_exists function.