Planet Drupal

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:

Notes from Mack Hardy's Drupal Talk

This month the Vancouver PHP Association and Vancouver League of Drupallers had a combined meeting. Mack Hardy of the Post Carbon Institution spoke on how the Post Carbon Institute was using Drupal to meet their organization's goals.

Mack has promised to post his slides, and hopefully there will also be a video of this presentation available. My summary forgoes the more involved details. Please check the slides for those.

Mack started with an overview of the Post Carbon Institute:

Post Carbon Graphic

Drupal Dojo Lesson Links

The Drupal Dojo lessons are now listed in a nice table of contents style format: Dojo Lessons and Links at the groups.drupal.org (aka D.O.) site: groups.drupal.org/drupal-dojo.

New BC Browncoats Website

Another Drupal website released into the wild:

www.browncoats.ca

Serenity in FlightThe Firefly/Serenity fan group is organized via the Vancouver Firefly/Serenity Meetup Group. The Meetup website has many advantages the group does not want to give up, but Meetup has a rigid format which doesn't lend itself to some kinds of content. In particular, announcements for charity events/sales are awkward because of HTML markup limitations and cumbersome URLs that don't lend themselves to publishing. The group wanted to enhance their web presence without creating a split personality.

The Drupal based Browncoats.ca site displays Meetup information via RSS feeds, leaving the group's two-way membership interaction with Meetup. People visiting the new site can see what's happening at the Meetup site and if they're interested are directed back to Meetup. The Browncoats.ca site provides a location for content that doesn't work well on Meetup as well as providing a nicer URL for promotional purposes.

AJAX & Themes

Serendipity is great, or maybe this is karma. I've been catching up on my Drupal mailing list reading. Caught an issue in the support forum I knew something about and my have been able to help someone, then saw the answer to a question I'd been meaning to investigate! Cool.

My personal/play site, Digital Doodles, has a custom theme, so I'm on the hook for updating it. When I upgraded to Drupal 5 I didn't get the AJAX goodness. I was fairly positive it was something simple I needed to add, and so it was. All I needed was: <?php print $scripts ?> in the head tag of page.tpl.php.

Template Theme Variables

[Update 2007-Apr-29: Please also see the article Theme Variable Total Visibility]

Have you ever wanted to know what variables the phptemplate engine made to the node or page templates? "Use the source, Luke" (Couldn't resist). The way of finding the definitive answer was discussed in Drupal Dojo today.

Pages

Subscribe to RSS - Planet Drupal