Get it All
Together

The last few weeks have been absorbed in some freelance work for a local marketing company, which is a nice change of pace. But that also means I’ve not been able to get at my new pet project in that time, which has been a bit of a downer.

And since that new project is CakePHP driven and I’m only really learning the platform, time away from the project means knowledge lost or at least deeply buried. That makes getting back into it something of a challenge.

And indeed, I took the better part of the last two days figuring out a problem which turned out to have been rather obvious. Obvious, that is, if you know where to look. But with all that out of the way, I’m starting to make some decent progress on the project and am hoping to get something that at least looks nice by the end of the week.

Because more than one recruiter has said they want something like this to point to as a portfolio item. Everyone seems pleased with the direction I’m going in: they like what the project’s aim is. Sorry I can’t share that on this blog, but until I’ve got my domain name in place, I don’t want to screw myself.

But I really like the layout I’ve chosen for this project: very clean with big, friendly fonts to draw in the less-technical. The project is supposed to be about lowering the bar of participation in government, so it’s important not to cram too much information on any one page.

Hopefully by week’s end: a preview of my new CakePHP-powered web site!

Oh, the drudge-work of webdesign. The repetition.

If you’re like me, you got into PCs back in the day because you found ways to make repetitious tasks go away when you used them. But sometimes in web design, there seems no way to avoid drudge work.

Ah! But then again, there’s always something. Whilst creating the newest version of my production site, DragonFlyEye.Net, I got sick to death of creating links. This was particularly true because of the way the page is put together: it’s using “clean” URLs, so creating a link to an article requires putting together a bunch of variables to make them look like directories to the browser.

The solution I came up with was a global function that created my links for me. All I had to do was pass it the needed variables, which are always conveniently held in arrays, anyway. I took the extra step (because, in my case, it was easier) of having the link-writing function write the whole anchor, including the bracketed content between the anchor tags.

Another advantage of using a global function to complete this task is that your links always come out consistently. If you want your domain to always be mydomain.com instead of www.mydomain.com, you can be sure that this happens when only one function is responsible for creating links.

For those of you who are not familiar with what I mean by “global function,” I mean that when I create a website, there are a few included files you can almost guarantee: a database incude file, a configuration include file and a functions include file. The configuration file contains all the usernames and passwords required to access special features (such as the database) of the site along with information such as mail servers and such. The database file includes only those functions which query the database, and again, this is for the sake of consistency and making sure that any problem querying the database can be tracked down to one location.

The functions file includes a list of functions which I find helpful where ever I am in the site, so I don’t have to constantly be copying the same function to each of those pages.  In my case, those functions include one to draw the correct number and selection of navigation buttons at the top of each page, a function to dynamically fill in sidebar content and a function that calls my DuckSoup Technorati API.  Of course, there is also a function that creates links for me.

I hope that this little blurb helps someone think in terms of compartmentalizing their code as I have done and avoiding unnecessary repetition!  Happy coding!