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.

Screencast on RSS

Brian Lamb PhotoBrian Lamb is an innovator in the local education technology sector, which is to say he's an online educator with a very active idea-hamster in his head. The stuff he's doing with RSS aggregative is wicked-cool.

In a recent blog post, Quickie screencast - distributed content publishing via blogs, RSS, whatever..., Brain gave a flavour of the possible.

The Loudness War

Tagged:

Saw this posted over at Inside Home Recording. Absolutely fascinating:

Website Revenue Generation Firsthand Account

Tagged:

Alex King at alexking.org gives a nice overview of the methods he used for generating income in this post: Building alexking.org 2.0, part 11: Monetization

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

Project Honey Pot Files $1B+ Lawsuit Against Spammers

Seen at Schneier on Security, Project Honey Pot is going after spammers in a big way:

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.

Pages

Subscribe to Group 42 RSS