Jody Zivtech Feed

Syndicate content
Updated: 53 min 16 sec ago

Fun with Theme Switching

June 16, 2008 - 8:40pm

UPDATE: CODE REWORKED THANKS TO CHX
<?php
/**
* Implementation of hook_menu (D5 code)
*/
function SOMEMODULE_menu($may_cache) {
  if (!$may_cache) {
    if ($theme = $_GET['theme']) {
      $themes = list_themes();
      if (isset($themes[$theme])) {
        $GLOBALS['custom_theme'] = $theme;
      }
    }
  }
}
?>
With this you can amuse yourself by browsing to /node/1?theme=marvin

I was thinking this could actually be useful- for example you could make an all xml theme and have Flash get data from path/to/page?theme=xml_theme

Drupal Node Access Explained

June 11, 2008 - 5:03pm

Drupal's API contains a pretty good description of how node access works (developers should also analyze the node_access function itself). There are many contributed node access control modules for Drupal and you really should understand the basics of node access before installing and configuring one. The API should suffice for developers but for the benefit of our many community members who build sites without reading code, here is a translation and some basic rules of thumb:

read more

HowTo: Add a freetagging form to a node display (Drupal 5)

April 23, 2008 - 3:49pm

This has been added to the Drupal 5 PHP Snippet section of the Drupal Handbook

I needed to make a little freetagging form to allow users to tag content as they view it - here's how I did it:

Set up a freetagging vocabulary using taxonomy.module and assign it to your content type as usual. Note the vid (vocabulary id) of your freetagging vocabulary (you can find it in the URL when editing the vocabulary). In a custom module, create a new form like so:
<?php
// form for adding tags to nodes
function MY_CUSTOM_MODULE_tag_form($nid = 0) {
  $form = array();
  $form['nid'] = array(
    '#type' => 'hidden',
    '#value' => $nid,
    );
  $form['tag'] = array(
    '#type' => 'textfield',
    '#title' => 'add tag',
    );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('+'),
  );
  return $form;
}
?>

read more

A simple shell command for drupal cvs checkouts

April 19, 2008 - 4:32pm

#!/bin/bash
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r DRUPAL-$2 -d $1 contributions/modules/$1

There are lots of great Drupal productivity / development modules (e.g. drush, devel, coder) which due to their nature as modules need to be installed on each site you work on. If you work on a dizzying number of different Drupal sites, productivity improvements which are not site-specific are the most useful.
NB: this post is geared toward Mac users.

read more

File-Based Content Templates

April 10, 2008 - 3:38pm

John Forsythe recently posted that Contemplate is one of the most favorited modules on his DrupalModules.com site, attributable to the learning curve of creating template files.

With no offense to Jeff Robbins who created this very clever module, I've never been a big fan of Contemplate. I don't like it when people store code and markup in the database because it makes it impossible for me to find where their markup comes from when I search the files. It also puts it out of the reach of version control, and creates the possibility of a white-screen situation which can only be fixed by going into the database directly.

But contemplate fills a real void created by the difficulty in per-field theming in Drupal 5. I posted about my method of handling per-field theming in content types recently and have been refining that method since. The purpose of my technique is to allow per-field custom theming without requiring additional work every time a new field is added. Essentially you print out any fields you would like to custom theme, and then you loop through all the other fields and print them all out in the order and with the 'Display Fields' settings as set in CCK. Although this method requires additional setup up front, it pays off when you add new fields (or modules that add new node content of their own) and you don't have to readjust your template (or contemplate).

read more

Hello Zivtech

April 9, 2008 - 9:39am

As Alex UA recently posted, we have recently partnered in Zivtech, a Drupal-only development business. I have been working freelance since coming to web development, and while it has been by far the best job I've ever had, I think that starting a business with a good partner with complementary strengths is going to be even better.

Alex and I are both Philly folks who are very passionate about Drupal. A key principle of Zivtech is to always work as part of the community, submitting patches as we fix bugs and add features for our projects, and taking the extra time to contribute to Drupal in many ways on a daily basis.

I look forward to working with everyone from this new role.

read more