Eternalistic Designs

Network Redux - Open source hosting

PHP

Because Network Solutions Sucks

One man's frustration is not lost in vain.

The Drupal community, and open-source community at that, has always had the altruistic goal of being accessible to all. The hope is that as freelancers and tech gurus go out into the world, maybe we can help by making better, more secure websites.

And then you have piece-of-crap hosting like that of Network Solutions.

Now, I only bring this up because as I work with clients to get their internet presence setup, sometimes you're stuck working with their choice of hosting provider, hosting package, and admin credentials.

This means crazy php.ini setups, no ssh access (because the cheap plans don't enable this), and passwords like '1234myfirstname'. Never the eternal pessimist, I figured I'd leave a few words of encouragement and one small tip to those that run into this.

First, don't give up. Although you can't convince your client to pay you monthly hosting fees on your leased vps (who hasn't tried that?), continue to make their internet presence more than a site built by iPowerweb. Yeah, you may have to wrestle with a table-filled layout, but a little progress is better than no progress.

Second, scour the drupal forums for a solution. Sometimes it may take a couple of days, but it seems like everytime I run into a roadblock, someone else has as well. A forked, non-hacked core, Drupal install on a POS hosting provider is STILL better than an MS Access-driven site hosted by 1and1. :-)

Third...if you're on Network Solutions, and get the dreaded email of 'we will not turn off register_globals or magic_quotes_gpc because it would affect other shared hosted sites', take a deep breath, laugh at them uncontrollably, blog about it, then put this piece of code in the cgi-bin of your vhost within a text file called 'php.ini':

register_globals = off
magic_quotes_gpc = off

References:

Google Maps/Amazon/Banned Books Mashup - Part 2

Geocoding with Google Maps API

When we last heard from Our Hero, we’d begun the joyous process of creating a simple Google Maps/Amazon mashup.  We took a peek at what the finished product should look like, we obtained our Google Maps API key, and we created our database tables and populated them with some data.  All good things.

We also talked about geocoding, that process of converting a street address into the coordinates (longitude and latitude) that Google Maps digs.  Our LOCATIONS table has some street addresses and empty columns just hankerin’ for some longitude and latitude info.  Let’s do us some geocodin’.
This zip file contains the source for all the codin' we're doing today:

http://www.nerdliness.com/files/updatelnglat.zip

You'll need those files to follow along at home.  While I'll break 'em down pretty much completely in the paragraphs to follow, I won't be reposting them in their entirety.  If you try to just copy-and-paste from the text below, you'll be sadly disappointed when your efforts blow up because of a missing variable declaration, etc.

 

References:

The Power of template.php

A few techniques to help your designers.

Theming a fresh Drupal site always gives the designers true glory. Well, its time that I help out my fellow programmers. After all, without us, its just a pretty drupal core.

First things first. I'm assuming that you and the designer are working on a clean theme, like zen. I'm also assuming the use of Drupal 5. Most of the code is available via drupal.org.

So what kinds of things can you do?

Custom id and class tags

The most important thing to know is that Drupal allows the modification of theme functions within this file. This means any function within a module or within the Drupal core that begins with name theme_xxx can be hooked into and modified to include elements to assist the designer, i.e. adding 'id' or 'class' tags.

Let's say, for example, you'd like to modify the menu items. Your designer wants to be able to add special attributes to each menu item, but needs a unique id tag for each list element. Because there is a theme_menu_item function in the core menu.inc file, we can simply create a phptemplate_menu_item function in template.php that overrides how the menu item is displayed. This avoids touching the actual core function (a big no-no in Drupaland) and keeps our mods in one location as upgrades are performed, assuming your template.php file is in the sites -> default -> themes directory (which it should be).

To add custom id tags to each menu item, as well as add an 'active' class when the user is on that particular page, try:

References:

Creating a Google Maps/Amazon.com/Banned Books Mashup

Part One of God Only Knows How Many Steps...

And now for something completely different…

Sorry to disappoint all the little nerdlings who come around here only for the Drupal goods, but today’s post won’t be at all related to our favorite CMS.  We’ve talked about different Drupaly topics for weeks, now it’s time to shake things up a little.  Today, kids, we’re going to make a basic Google Maps mashup.

Yeah, I know.  The world needs another Google Maps mashup like I need a hole in my head, right?  Who cares.  They’re fun, and we’ll try to make our sample a little more interesting by throwing in a little Amazon.com action and some AJAX-y goodness.

So here’s what we’re shooting for:

http://www.nerdliness.com/ajaxdemo/

First of all, don’t laugh.  Jeremy’s the form guy, I only do function.  Sure, it ain’t much to look at, but it works and it’s kinda cool.  And if we wanted it to look nice, we’d pay Jeremy his surprisingly reasonable freelance rate to pretty it up for us.

Ok, so what’s the big deal?  What are we doing on that page?   In a nutshell, we’re plotting, on the fly, the locations of every public school in Texas that, according to the ACLU of Texas, banned a book during 2006.  I took the data from a PDF they release annually (http://www.aclutx.org/projects/bannedbookspg.php?pid=45) and used it to populate a MySQL table with the various data you see by clicking on the assorted links. 

References:

Drupal Adsense Injector Module with CCK

You might notice a rash of Drupal-related posts over the next couple of weeks. Last week, we decided to port the site over to that very popular CMS, mostly because we outgrew WordPress in about 3 days. Don't get me wrong, I love WordPress for straight bloggin', but it's a little limited on the pure CMS side of things. Still would recommend it to anyone who just needs a blog, though (I still use it for my personal stuff).

Anyway, today I installed the AdSense Injector module (Nerd's gotta eat, right?) after reading about it on the Drupal site. We'd previously added some AdSense blocks, but I liked the way the AdSense Injector module claimed to insert the ads in more visible locations (like the one you saw at the beginning of this article).

So I downloaded the module, unpacked it, activated it, set it up, refreshed a page... and nothing. No new ads.

A little investigation quickly pointed out the problem: AdSense Injector assumes you have a Body field in your content type. Unfortunately, our articles are written using a customer content type created with the absolutely essential Content Construction Kit (CCK) module. Furthermore, to have more granular control stylizing our template, we've removed the normal body module and replaced it with a custom field. Seems the AdSense Injector module didn't like that.

The good news is that the AdSense Injector module is pretty straight-forward, so editing the module to fit our needs was simple. All we had to do was modify the adsense_injector.module file in a few places to look for our customized field and voila! You can now see (and, hopefully, click) the well-placed Google AdSense ads at the top and bottom of each post.

The specific lines we changed were:

References: