If Only I Could Strike Back At The SEO Consultant Slime

Nothing makes you feel "not so special" like having the majority of your daily comments -- that pass captchas mind you --  left by bottom feeding SEO consultants. Now before I explain why these consultants are bottom feeders, and why you could teach an 8 year old chimp to do their job* (which they charge upwards $75.00 by the hour!... adding insult to injury) let me tell you why I can't defend myself.

Will the Internet Twitter Away, or Resurrect Literature?

A friend of mine, Anthony Alofsin, started a blog. He's primarily know for his contributions to the field of architecture, as a professor, and author of over 20 books on the subject. His interest in blogging, however, is literature, and -- i think -- challenging, and subverting a few of today's fashionable institutions of thought.

His first entry contains a manifesto:

On Bureaucracy

The behavior of any bureaucratic organization can best be understood by assuming that it is controlled by a secret cabal of its enemies.
-Robert Conquest's Second Law of Politics

Art Vs. Fashion Vs. Design

It’s art if it can’t be explained.
It’s fashion if no one asks for an explanation.
It’s design if it doesn’t need explanation.

-Wouter Stokkel

Food for Thought

"I believe the hard part of building software to be the specification, design, and testing of this conceptual construct, not the labor of representing it and testing the fidelity of the representation. We still make syntax errors, to be sure; but they are fuzz compared with the conceptual errors in most systems."

-

Fred Brooks, No Silver Bullet

jQuery 1.3: Part of the Big Deal

I know I'm not among the first to hear: jQuery 1.3 . Why is it worth supporting aggressively? Here's one reason:

This creates another paragraph that -- here it is -- you can click on forever to repeat the same behavior.

If that sounds freaky, look at this chart on the performance implications:

PHP5 Reflection And You

Drupal:

The phpdocs put it kind of weirdly:

PHP 5 comes with a complete reflection API that adds the ability to reverse-engineer classes, interfaces, functions and methods as well as extensions.

I prefer the notorious c.h.x.'s definition

chx: it's like this insane cool weaponset of PHP which is like totally unknown :)

Reflection is a very powerful too that lets you understand the code running in your enviroment. This is particularly important for drupal development, as so much of drupal is based on functions that call functions (e.g. hooks).

The point of this tutorial is to show you how much ass reflection can kick, in so little code. The following page finds out every menu item that calls a function hidden away in a remote file, and gives you the location of the callback function: filepath, and line number and all. Note that the vast majority of code is merely used to output the test table. Obviously, this example merely scratches the surface of useful things you could do with this api.

hook_views_query_alter : alter views queries with array keys

While building a product comparison website, I ran into a situation that required a view to sort using one of 2 possible price totals depending on a users profile: lets say "red state", "blue state". The goal was to open up the product comparison tables (order, fields, field names, and filtering questions and all), as well as the underlying data to this companies' staff, so a homebrew wasn't an option (which it shouldn't be, almost 99% of the time).

Luckily, there were only two possible prices for those products, so all I had to do was create two CCK *decimal* fields [ this is important, because text, and integer fields don't properly store or sort decimal points for prices ]. Then, on hook_cron, or a node submit, I updated the two totals based on other itemized fields.

However, how would the view know which column to sort products by based on a flag stored in the users session? There's about 5 ways to do that, so I went with the 1 minute solution:

Set up two sorts in a single view, and implement hook_views_query_alter(&$view, &$query)

<?php
function product_compare_views_query_alter(&$view, &$query) {
// fyi, anonymous sessions need a record in the user table of 0 to work at all....
 
if ($_SESSION['pref']['state_color'] == 'red') {
   
// we'll have to do the less popular red query
    // which's key is [1] (weighted second in the views sort order interface)
   
unset($query->orderby[0]);
  }
  else {
 
// otherwise, don't do the hill billy logic at all....
   
unset($query->orderby[1]);
  }
}
?>

Discussion

In theory, you could write a custom algorithm that built its own sort queries based on a criteria using this method. You could also probably alter filters, or fields. However, this isn't the only way to have accomplished this -- but its the easiest for me to stomach. Never use this method when existing views features, or view arguments, or even other views hooks may be the proper hammer for this nail.

If I learned anything, its that views a complex beast; flexible like F-22 -- an amazing piece of technology that offers tremendous freedom -- but often that freedom will cause you to crash in the ground if you don't think about what you are doing carefully.

Blueprint Vs. 960

The starter guide in my last entry practically gives you an intro to the 960 framework as well. The names are different, but the approach is the same. Though 960 is a bit more complex. .container-x, and both "first" and "last" classes (named alpha, omega, pretentiously enough).

I decided to checkup on a drupal groups thread that discussed CSS frameworks AFTER I hit publish. As it turns out, a 960 theme is on its way to drupal core.

Pages

Subscribe to Nick Lewis: The Blog RSS