Trailing \r

I built a method in PHP that generates dynamic dropdowns based on a few parametric inputs.
It was working just fine, except for one, which happened to be the field describing how the item was constructed. In our case, the only value after "GROUP BY" was 'Bolted'.
The dropdown generator has a 'Selected' determination check, and it wasn't triggering the correct item on the construction field. Commence bug chasing.

After some head scratching and some attempts at using PHP's trim() and filtering, I went to the view source to see what my outputs were specifically.

Continue reading


We had a slider that we liked. It had live text, which was a bonus.
We were on a super slow network.

Symptoms: Jumbled live text was showing up during loading down in the bottom left corner of the slider box. Not pretty.

Solution: This is not fancy Javascript. This is practical Javascript.

(document).ready happens before (window).load. Hide the headers, buttons, and ul dots on page-hit. Make them show back up when loading is done (unless we don't want to... like the bullets on the ul.). Easy peasy.

Continue reading

CSV to MySQL Import - Batch File - Improved

Keeping this one brief...
I got excited once the first import worked so well, and operated so quickly.
I then wrote some more specific import strings for the 'load data infile' command.

This next one dictates the intended targets of each sequential column in the .csv.

It's worth stating that I had to change my Windows default separator for a .csv to a semicolon, as some of our fields had regular commas in them.

Continue reading

CSV to MySQL Import - Batch File

I'm not going to claim that this is the most efficient way to do this, but I got it to work quickly going this route.

The purpose of this script was to provide a folder location for less-technically-inclined folks to place a .csv with their most current sales office information. Names, addresses, and numbers change from time to time. We made a mechanism to import their .csv nightly, so that our lookup tool had the most recent data without needing a developer for every minor update.

Continue reading

Drupal GoTo in New Window

I'll get right to the point.
drupal_goto(target); Can not accomodate a target="_blank" designation. You can't do it on the server side.

Here's what you can do:

Make some jQuery/javascript that will sniff out your applicable a elements, then force add the target="_blank" attribute.
Here's what I used.

Continue reading

Drupal Revisioning

Drupal's canned revision system is an excellent, easy to use tool that adds one more layer of backup/version control.

I'm not saying I'd depend on it completely, but I will say that it makes user error recovery ridiculously simple.

Continue reading


Why not?

I set up two schedules on a couple websites that are close to launch.

Really, the backup files aren't too terribly big. So I set up one folder to do my daily backup, and I keep 7 of them.
Then, I set one to be hourly, since we're in crunch time, and multiple folks have their fingers in the system. If something goes wrong, I don't want to be unprepared.

It's not hard at all. 10 minutes to set up both, tops. Do it.

Hourly database backups. I keep 24.
Secondary daily backups. I keep 7.

This will be revisited when the heat comes off.

Continue reading

Drupal Modules and Regression Testing

'Twas the night before a controlled release to stakeholders for some VoC and user testing,...

Last night I had a dangling storm cloud of uncertainty on a previously working module.
Previously, our products were categorized appropriately and effectively. We had a dynamic taxonomy/term/% view that was doing its job. Life was good.

Continue reading

Increasing Field Length Restrictions

I had limited a field in our 'Alternator' content type to 50 characters. Our client wanted the field to be bigger, and Drupal by default says, "

This is the solution I applied, in template.php:

I renamed the methods to match the template. Then I called the function in an inconspicuous place on the site. It worked like a charm.

Continue reading

Drupal Preprocess Redirects

This doesn't need a huge explanation, we were looking to redirect a single node to an external site.
I used to do this by placing a response.redirect in an asp file.

One way I got this done today was in the Drupal template_preprocess.

In your theme's template.php,

function themename_preprocess(&$variables, $hook){
if ($variables['node']->title == 'Target Title'){

Continue reading