Planet Drupal

New Zend Podcast: PHP Abstract

Zend has a new PHP Developer Podcast called PHP Abstract:

PHP Abstract LogoEach episode features a different special guest bringing you their expertise, compressed into a five to seven minute package.

We will be covering a broad range of topics. From security to project planning and hiring good developers and much more.

Their first podcast, PHP Abstract Episode 1 - PHP Security Tips, featured Eli White. What a relief to have someone skip over the same rehashed security material into things less commonly talk about.

Off to a good start in my books. At under 10 minutes a shot I'll be subscribing to check them out. (And have already suggested Dries as a great guest choice! ;)

Creating Links (aka Anchor tags) - The "l" Function

Note: This article covers the l function for Drupal 5. While most of the information is still applicable to Drupal 6, the function call has changed. See http://api.drupal.org/api/function/l/6 for the Drupal 6 version of the call.

Why would anchor tags warrant attention? It's just a text string after all. Concatenate a variable or two with some text to create the link and you're done, right? Maybe.

Do you want to move your code between different Drupal installations? If the answer is yes you need to worry about handling the differences between servers, things like whether clean URLs (1) are enabled or the instance is installed in a base directory (2).

Having to test and determine output based on specific conditions sounds like a good candidate for a function. The Drupal programmers who came before you though so as well, thus we have the "l" function.

The l function brings with it other advantages. If the link is Drupal content with a URL path alias the l function will automatically use the path alias, even if it's passed the Drupal "system" URL. If the URL you're specifying happens to be the current page, it automatically adds class="active", which is very handy when using CSS to theme navigation links.

Theming 101 – The theme_table function

I come to you as one reformed. I will no longer use foreach loops to build tables. At first, I did not know about theme_table. Then I couldn't be bothered to learn about it. Then, after feedback from people whose opinion I respect, I felt compelled to bite the bullet. I wish I hadn't waited so long.

Overview

As the name suggests, theme_table is a Drupal theming function for creating tables. It takes arrays holding the table data and generates the HTML for displaying the table. At their simplest, the input arrays hold text elements. At their most complex, the arrays hold arrays which hold arrays. The various arrays all hold data appropriate to their location, so this isn't as bad as it sounds.

As with all Drupal functions, there's documentation at api.drupal.org. For the Drupal 5 theme_table function specifically: api.drupal.org/api/5/function/theme_table. There's enough there to get you started, but you still have to think a bit. (Which is to say, I had to. Think a bit, that is.) Thinking should be reserved for the problem at hand, not figuring out Drupal, so here's my "overflowing with examples so you can cut and paste" explanation of theme_table.

April 2007 Vancouver League of Drupaliers Meeting

April 26, 2007 saw a close encounter of the Drupal kind at the Bryght offices in Vancouver's Gastown. Attendance wasn't counted but people were scrambling for chairs. Meeting topics included:

  • OSCMS Roundup
  • Drupal 6 Update
  • Scott Hadfield's Summer of Code Project on Drupal Scalability
  • Install Profiles
  • Pro Drupal Development Book
  • General Q&A

What follows are my notes from the meeting, including audio excerpts (Recording credits go to Roland Tanglao and myself).

April 2007 Drupal Meeting

Video Sharing Implementation Discussion

An interesting post at Open Academic on doing video in a variety of CMSs, including Drupal:

DIY: Private Video Sharing for a school, a district, or an organization

Theme Variable Total Visibility

Need to know absolutely, positively, and without-a-doubt what theming variables are available to your template? Here's a trick for total visibility.

In my previous post, Take Control of Your PHPTemplate Variables, I described the _phptemplate_variables function in template.php. It's passed a parameter named $vars which is an associative array of all the variables that will be created in the template . . . which is exactly what we're looking for!

Since _phptemplate_variables allows us to create theme variables, we have a simple way to get the $vars data into the template where we can look at it. Just put the following code in your template.php file:

function _phptemplate_variables($hook, $vars) {
  return array('vars_data' => $vars);
}

And the following code in your template file:

Take Control of Your PHPTemplate Variables

For your templating pleasure Drupal's PHPTemplate engine makes available a cast of variables, including such favourites as $title, $content, and $node. Modules also contribute: CCK adds CCK specific template variables as well as fields to the node object, and the comments module adds an entry to the $links variable. But what happens when something isn't formatted the way you or your customer wants, or you have a project specific variable you want to add?

Introducing the _phptemplate_variables function!

The _phptemplate_variables function lives in your theme's template.php file and is called by the PHPTemplate engine after the various modules have done their thing, and before PHPTemplate actually renders your node into HTML. _phptemplate_variables provides a single, common location to all .tpl.php files for adding or changing variables.

ONLamp.com Drupal/CiviCRM mention

Drupal/CiviCRM gets a prominent mention in this ONLamp.com blog post: Top Drupal & CiviCRM Gotchas

Seven of his ten points are good to know for any LAMP based system, and some are aimed squarely at the new (e.g., do backups). Great information for someone starting out, but given the general nature of the information the post is a little misnamed.

Simon Willison's Slidecast on OpenID

OpenID LogoI've been hearing a lot about OpenID the last six months, probably because Sxip and Bryght have a local presence. It's a cool technology solving a problem I certainly deal with day-to-day. But will it rise from the primordial idea soup into mainstream acceptance? According to Simon Willison, yes:

When Bill Gates stands up at a security conference in America and spends seven minutes on stage talking about a technology, it's not really a niche proposition anymore.

Evil Ben and MenaWilson recently gave a talk that was converted into a "slidecast": http://simonwillison.net/2007/Mar/12/slidecast/. It does an excellent job, the best I've seen to date, of explaining OpenID and the problems it's meant to solve. I appreciated his inclusion of a "What's wrong with it?" section. And it's not without humour, we're introduced to the evil alter egos of Ben and Mena Trott!

More Lullabot Article Goodness: Forums & CCK

Lullabot

A shout-out to the folks at Lullabot for their latest articles:

Pages

Subscribe to RSS - Planet Drupal