Drupal Tutorials

Enabling/Installing New Modules via Update.php: The Complete Solution

In our last episode of enabling new modules via update.php, Steve McKenzie pointed me to a better method: module_enable(). A quick test found, however, that it didn't run the install files, and didn't rebuild the module files cache. So after spending 5 minutes in system.module, I found all the missing pieces. The example update function below will install and enable the new module, as well as rebuild all the css, node type, and menu caches.

Enabling New Modules Via Update.php

UPDATE: There's a better way.

I work with 3 other developers, all of whom have their own local sandbox of our site. Since we're constantly adding new modules, I found a simple way to enable a new module via another module's .install file. That way, all we have to do is run update.php when we update our source tree.

Here's a simple example update function:

<?php

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:

Pages

Subscribe to RSS - Drupal Tutorials