Drupal Tutorials

Drupal trick: Returning a themed menu tree with nothing more than the system path

I remember something a long time teacher said, "Nick, if you make a suit out of a gorrilla, the arms are too long." I forgot why that was relevent to the topic of theming menu trees.

Moving on, here's a nice little function I wrote to return a themed menu tree by path.

<?php
// will return all menu items under "administration".
print theme('menu_tree_by_path','admin');

// will return links to all node submission forms
print theme('menu_tree_by_path','node/add');

// return the correct menu array by path
function menu_get_mid_by_path($path) {
// oddly, menu_get_item accepts a path, but returns the parent id.

7 jQuery Plugins That Made Our Lives Easier at ON Networks

We, the developers of ON Networks released version 1.1 of our website this evening (its built off of drupal of course... if it weren't, than I would go sharing it with the planet, would i?). The notable improvements are ajax comments, tooltips for episodes, and a global navigation.

The Key to Jquery Form Plugin + Drupal Formapi

Today I bring you an incomplete, yet stunningly easy solution to a problem that's been making want to set buildings on fire.

Let Template.php Eat Static

 My arch-nemisis is overly complex logic in template.php and page.tpl.php files. It seems to me that when a drupal codebase becomes brittle and unmaintainable, the culprit is usually going to be hundreds of conditional lines of php code in a template file. You've probably seen code like this before:

THEMES/SPAGETTI_MONSTER/TEMPLATE.PHP

Going Global in Drupal: Too good to be true?

There is a timeless law that every serious blogger needs to remember. As this law doesn't seem to have a name yet, I'm naming it Gillmor's law , after Dan Gillmor. Roughly stated, the law is:

"Your readers know more than you do."

I've discovered a solution to a common drupal programing problem: how to avoid excessively running something along the lines of "$node = node_load(arg(1));" in hooks or functions that don't have node data available to them.

The solution was so easy, and had so many different uses in different contexts that I'm nervous, and know that I must have done something idiotic. Thats where you, my dear reader, come in[1].

Neutered Nodes: CCK's Dark Secret

Update 2 (march 1st, 2007)

Thanks to numerous improvements in CCK itself, and drupal 5.0, I now officially disagree with myself in this article. My criticisms last October no longer apply -- CCK now makes everything easier, and I've personally had an easy time pushing changes from development, to stage, to production using CCK. Consider this article a historical curiosity. (More info...)

Update: this is a fairly contentious claim, so be sure to read the discussion in the comments

When planning the development of a drupal site, be wary of using the content construction kit (CCK). While its one of drupal's most powerful modules, its also probably one of the most inappropriately used.

The Road to Drupal Hell

Hell Opens Up New Exclusive Layer for Drupal Developers

(PRWeb) -- Lastweek, the Drupal Content Management System became the first opensource CMS to have its own layer of hell. Though many proprietary CMS's, most notably Vignette, have long had their own exclusive parts of hell, this was a first for open source.

Vincent Pendragoon, a spokesman for the Lucifer Ventures, described the new layer as a place for "Generally inexperienced, slothful, or overconfident developers who don't bother with things like APIs." When asked whether this meant hell would put a new emphasis on open source, Mr. Pendragoon replied, "Hell is merely acknowledging the amount of misery open source can inflict."

Learning How To Theme in Drupal, Starting at Square One

Note: I'm going to start regularly answering questions I get via email by blog. The reason being that email is a blackhole; and I am getting too many good questions everyday. When I have a few moments to answer, I figure I should make them available to everyone.

A reader by the name of Fouad writes:

How to create a block region for node.tpl.php

Update: appparently, today was the day to write about this. Nedjo Rogers submitted a handbook page that shows a different method of achieving the same end.

For the most part, Drupal 4.7's block system is underutilized. This is a shame; with the proper templating, drupal's block system can become a valuable workhorse. In this tutorial, you will learn:

  1. How to override default functions in the phptemplate.engine
  2. Create new regions to place blocks
  3. Pass a block region into node.tpl.php

By the end of this tutorial, you will have the ability to place blocks into node's like a so:

Quick and Clean CCK teasers Via PHPtemplate

If you are like me, you've been pulling your hair out trying to make teasers work in CCK. Well, as it so happens, I figured out a crazy simple phptemplate method of making CCK body fields act like any other node's body. Observe:

Pages

Subscribe to RSS - Drupal Tutorials