Die, Derek, Die!
A little Simpsons joke right off the bat to warm up the crowd after nearly a two month absence from the Great Hall of Developers. One might say that Derek is the quintessential non-yes man. I request a simple confirmation that an idea has merit, and then an hour later I am befuddled with his five alternatives. Such a man is trouble, people. Thankfully, he does fine coding and saves me from troubling affairs of state, so I guess it all works out. Good night, Derek, good work, sleep well, I’ll most likely kill you in the morning. That sentence concludes my opening paragraph and includes an obscure movie reference, yippee!
Nothing substantial nor interesting about technology has made itself present in the conscious regions of my mind lately, so instead of expounding I will present a gift and hope for the best. Derek and I are rather bullish on extensions lately as we continue creating new ones ourselves, and a couple weeks ago I created another new extension for the ExpressionEngine.com site that I thought I might share. This new one also uses AJAX so I am sure a few of you need a cookie and milk to calm down.
I present to you the AJAXified Edit Tab extension. Instead of submitting the search form (and reloading the page) when doing a search, the extension now dynamically updates the list of entries displayed by using AJAX. No more page reloads and the filtering of results becomes quicker and snazzier. Basically, all of the search form pulldowns and the Exact Match checkbox have javascript added to them so that whenever one changes the list of entries is updated via a javascript function called ajax_edit_tab(). Look for it in the HTML source. The Keywords text field requires that you actually click the ‘Search’ button though. Since a site could have anywhere from one to a hundred thousand entries, it seemed wasteful to update the results on every single character added or deleted from the field. One could easily change that by giving that field an onkeyup=”” attribute and setting it to ajax_edit_tab(), if they so desired.
A relatively simple little extension if you have a bit of javascript know how and one that I actually had thought to create well over a year ago. Back in November 2005, when I started writing the script that would one day become the Simple Commerce module, I realized that the Edit area’s display and search functions should be abstracted a bit more so their functionality could be used elsewhere in ExpressionEngine. If you have ever used the Simple Commerce module, you will notice that its Add Items page is nearly an exact replica of the Edit area. They both use the same PHP method for creating their search form and results. One has to love abstraction.
This actually happens a great deal in ExpressionEngine’s code. For example, there had been a plan to have extensions in the code base for years before they appeared and there were various little things in the code we did to make it easier to add hooks even before there were hooks. It is a nice little game of ‘what if’ on the part of developers. What if we want to use this code again? What if we want a method to serve a future purpose even though we only have this one need today? What if a third party developer wants to use it?
No one can perfectly plan the future, alas. A few features I added to the Template parser back in ExpressionEngine 1.4 (released in early 2006) for use in the Commerce module were finally going to be taken advantage of at the end of last week, but while writing the module code I realized I had forgotten a very crucial ability. Oops. Ask Rick, I was rather cranky about it.

