PHP

Allowed Values pulled from Table

Fred's picture

A simple method for pulling Allowed Values for a CCK Select List field:

$sql = 'SELECT p.`partno` FROM {nrg_custom_monitor_part_numbers} p ORDER BY p.`partno`';
$result = db_query($sql);
while($row = db_fetch_array($result)){
  $rows[$row['partno']] = $row['partno'];
}
return $rows;

Note that you need both a key and value!

Theming CCK Input Forms

Fred's picture

Theming CCK forms initially appears to be a bit of a black art, but is very simple. The simplest method is to add:

function phptemplate_node_form($form) {
  if(file_exists(path_to_theme().'/'.$form['type']['#value'].'_form.tpl.php')) {
    return _phptemplate_callback($form['type']['#value'].'_form', array('user' => $user, 'form' => $form));
  }
}

to either your theme's template.php, or to a custom module for greater portability. Then create a content_type_form.tpl.php in your theme folder.

Quick and Simple Tips

Fred's picture

The code design of Zen Cart is sometimes baffling, sometimes plain ugly and other times just plain WTF?! Even the most seemingly obvious task takes longer as there is no central location for themeing and for something that touts itself as "not for programmers", there is a hell of a lot of editing of obscure code files scattered throught the installation.
Here I have tried to note down some of the more common, or at least common to me, items I need to keep track of.

Zen Cart

Fred's picture

Zen Cart is a very popular shopping cart system forked from oscommerce. While the Zen Cart homepage claims that it is easy to install, configure and use, sometimes the method of changing options and features can be a little confusing. Whatever you do, don't get me started on their theming - it's not pretty.

Drupal Hints & Tips

Fred's picture

During my exploration of Drupal, there are times when I need to note down helpful hints and tips. Some of them are complete and can be used as-is, most are just pointers.

Syndicate content