Drupal views_embed_view() Returns NULL Result

File this one under "Stupid Mistakes".

I recently spent an obscene amount of time troubleshooting one of my bone-headed mistakes. Views 2 has a function called function views_embed_view($name, $display_id). This function accepts the arguments that are to be passed into Views for refining the result set. When using it this time I kept getting a NULL result, which was driving me nuts and totally inexplicable. I'd stared at the code for so long, and read so many blog entries and forum posts I ended up looking right past the problem. It took opening the Views source & actually reading through the function to locate my error (ummm... oops!). I was using something like:

views_embed_view("content_list", "block_1", Array($arg1, $arg2, $arg3));

Some of you already see the problem. Somewhere I'd gotten the impression that there were three arguments, but there are not, the third argument to the function is not an array of Views arguments, but rather all views arguments should be just added on to the views_embed_view function arguments list, like so:

views_embed_view("content_list", "block_1", $arg1, $arg2, $arg3);

Most people reading the Views documentation or copying an example will not have this problem, but on the off change that someone else is looking (or I make the same mistake in the future), the fix is simply to not pass the Views arguments inside of an array.

The more interesting part about this experiencing is in reinforcing the idea that the best documentation you can read is the source code you're working with. I spent a lot of time searching the web, but all of about 20 seconds looking at the actual source before seeing the problem. Being more familiar with the source I'm working with would have saved me tons of time. Next time...

Scripting Apple Mail to Evernote

Email is a great way to send info but the point of an "IN-box" is to get the email OUT of it and into a place you can do something with it i.e. (Merlin Mann / Inbox Zero). And, no, that doesn't mean another folder somewhere in your mail client. That means your to-do list, calendar, etc... But what about the bits you want to keep track of but you don't really cause you to need to do something? Evernote is a great way to keep track of things you want to remember and I've increasingly found myself moving mail messages into Evernote for later reference. Unfortunately I'm lazy and the copy/paste process is far too tedious. If I wanted to fill my life with such drudgery I'd be using Windows.

Here's a simple script you can add to your Mail Script folder. The script will add a new Evernote note with the selected email message subject as the Note title and the email contents as the note body. It will create a new Notebook called Mail Archive to which all Mail notes will be added. It also sets the note creation date to the date you received the message. Not the date you added it to Evernote.

Webrick Without Rails: A great lightweight standalone HTTP server for previewing

One of the constant annoyances I seem to run into is the need for absolute paths in my web work. Whether it's publishing an HTML layout with the need to reference all of the images from the root directory (e.g. '/images/') or building a Flash app with the same need, I seem to run into quite a few situations where you never know what directory the final product will end up in and relative paths just won't do.

Previously, I'd taken the approach of using relative paths in development and then changing the references just before doing a final test on a development web server. While this works fine for the initial round of work, it becomes pretty tedious to keep switching back & forth as you move through changes and revisions. One of the things I've always liked about Ruby on Rails is the ability to run a built in web server for local development, which entirely eliminates these issues. Rails will run a web server called Mongrel if installed, but (I believe) still falls back to a pure ruby server called Webrick. Webrick, however has no need for rails in order to run (though it does require Ruby) and makes a wonderful little HTTP server for down & dirty development.

If you are on a Mac you've already got Ruby installed and this should work. If you're on Windows you can install Ruby but you're on your own on that one. Once installed you'll want to create a quick ruby script and set to be executable. The contents of your script would be as follows:

#!/usr/bin/ruby require 'webrick' include WEBrick httpath = File.expand_path(File.dirname(__FILE__)) puts("Serving: " + httpath) s = HTTPServer.new( :Port => 2000, :DocumentRoot => httpath ) trap("INT"){ s.shutdown } s.start

The httpath variable is set to the directory containing the script itself, so you'd essentially place the script inside of whichever folder you want to be your document root. The port is set to 2000. I include this file in each of the projects I create and when working I can just quickly run the script (I call the file 'servthis') and point my browser to 'localhost:2000'. Now I'm free to use absolute paths to images or XML files in my code without sending files over FTP to a "real" server.

Stepping Backward is Moving Forward

About a year ago I took on the role of project manager for Inspyre, a Tampa based web design and CMS hosting company. I'd been with the company several years prior as a developer and the move, at the time seemed to be a good one. There were benefits to the move, both in my career and in my personal life as well as an opportunity to grow experience in an side of the industry that I was arguably the weakest in. I am very glad I made the move at the time and very glad I'm making the move out now.

I learned a lot of things in the past year, that are valuable life and business lessons I'll carry with me for years to come. Maybe most importantly I've learned what it means to try to do a job and come to grips with the idea that you're just not passionate about it.

Inspyre's business model is largely based on rapid turn around of repeated small to medium sized web site projects. As such, the management of their project list is never slow, but also rarely changes. The daily task you're completing today will be the same task that shows up on your list in three months. I've realized this is a huge problem when your life has been spent, in one way or another, creating things. When your passion is to see something new take shape and see something of yourself inside of it, a year of repetition, no matter how good your intention, begins to become a rather serious weight, and you begin to resent the weight, and unfortunately sometimes the company or people that are "placing" the weight on you.

Lessons learned, value received, experience gained, it's now time for another change, in this case back into a development role. I'll still be with Inspyre (despite the occasional stress points I really do love the company) but I'll be back into a position where I'm able to do the things I'm passionate about doing. Throughout my time as project manager I kept involved in several development projects along the way, including building the Inspyre Media Player. Those were the times in the last year I felt the most awake, alive, and committed to my role, and it's obvious to me that it's the role I belong in.

I'll be in a transitional period for the next few weeks, mentoring my replacement and assisting general production of the daily projects we're working on, but some of the projects lined up for the near future are very exciting. Last night was my first meeting with the company owners returning to more of an active development role. We began mapping out a new project that is going to be great for the company and also looks like something really enjoyable to be a part of. It has some unique challenges we've identified and some really great opportunities to be something unique.

In keeping with the theme of returning to older things once placed on hold, I've decided to bring CliffPruitt.com back online. I've not really decided what exactly it's supposed to be other than a place online to keep my junk. As I'm taking the time to deliberately refocus on the things I'm passionate about and the things that spark or result from creativity, this seemed like the natural way to give it a big fat leaky umbrella to fall under. It may be a disjointed frankenstein of mismatched parts but so what? At least I'm making things again.