Beauty’s where you find it
27 Jun
jQuery took what would have been a 4 - 6 hour job ordeal and turned it into 10 minutes of pure enjoyment. Read on.
One of our clients at work has a site which is maintained with Dreamweaver (DW) templates and Contribute. If there is anything I have learned about this combination, especially DW templates, it’s that updating templates/libraries and pushing those updates to pages can become increasingly painful as a site grows. This particular client insisted on the template/Contribute route, and at the time we couldn’t make a solid argument about why they should not pursue this solution to content management (we now have that argument). We are on a maintenance contract with this client and once per week we have requests to update content. Because I did the initial setup, and because I have the most experience with DW, this job falls on my plate. Here’s the rough flow of data management / updates.
This process is time consuming, slow at best, and very frustrating. Now I would normally be working on other tasks while files are being checked in/out, however that’s not the point. This whole workflow makes we want to vomit.
Today we had a request to add a footer to each page in the site, where previously there had been no footer. That’s an update for every template file, and every page in the site. You might be thinking, why didn’t you initially add markup for an empty footer, or at least add an include that pointed to an empty file? We didn’t, but that is a good idea. Instead, I took what would have amounted to 4 - 6 hours worth of mindless, brain numbing work (believe it or not, it would have taken 4 - 6 hours), and instead implemented a javascript/php include solution. This took about 10 minutes. Here is the markup.
$.get("/assets/php/includes/footer.inc.php", function(data){
$("#wrap").after(data);
});
As you can see, I created a footer include file, used jQuery’s get method to retrieve the contents, and inserted those contents after the main wrapper div. I chose to pull the contents of the footer from an include file in order to make future updates of that content more manageable. I wouldn’t want a future developer pecking around in the JavaScript just to update the footer. That would be just plain wrong.
In the world of web development implementation typically isn’t the issue. Figuring out the proper solution usually takes more time. What I’ve done here isn’t rocket science, but it did save me hours of time, while not sacrificing future application maintenance. I can live with that.
Leave a reply