Session 4 H: Open session: Hacking and other fun stuff

Events happening in the community are now at Drupal community events on www.drupal.org.
Petrina's picture
Start: 
2006-06-29 10:00 - 12:30 Etc/GMT

you decide!

Comments

backup shell

dalin's picture

backup shell script
http://drupal.org/node/59369

devel module
http://drupal.org/project/devel

database administration
http://drupal.org/project/dba

--
dave hansen-lange

--


Dave Hansen-Lange
Director of Technical Strategy, Advomatic.com
Pronouns: he/him/his

Forms API Quickstart Guide

nally's picture

Here is the forms quick start guide.

http://drupal.org/node/36050

Forms API Quickstart Guide

nally's picture

Here is the forms quick start guide.

http://drupal.org/node/36050

test module

Steve McKenzie's picture

<?php
/**
* test.install
<em>/

function test_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      db_query("CREATE TABLE {test} (
      nid int(11) NOT NULL,
      new_field varchar(250) NOT NULL,
      timestamp timestamp NOT NULL default CURRENT_TIMESTAMP
    ) TYPE=MyISAM /</em>!40100 DEFAULT CHARACTER SET utf8 */
;"
      );
      break;
  }

  drupal_set_message(t('test module was successfully installed.'));
}
?>

<?php
/<strong>
*   
test module
*/

/</
strong>
*
Implementation of hook_help()
*/
function
test_help($section) {
  switch (
$section) {
    case
'admin/modules#description':
      return
t('test module.');
  }
}

function
test_settings() {
 
$form['field_set'] = array('#type' => 'fieldset',
 
'#title' => t('field content'),
 
'#collapsible' => true,
 
'#collapsed' => true
 
);

 
$form['field_set']['test_node_types'] = array('#type' => 'checkboxes',
 
'#title' => t('Available Node Types'),
 
'#default_value' => variable_get('test_node_types', node_get_types()),
 
'#options' => node_get_types()
  );

  return
$form;
}

function
test_form_alter($form_id, &$form) {
 
$nodes = variable_get('test_node_types', node_get_types());

  foreach(
$nodes as $node_type) {
    if (
$form_id == $node_type .'_node_form') {
     
$node = node_load(array('nid' => arg(1)));
     
$form['new_field'] = array('#type' => 'textfield',
     
'#title' => t('New Field Title'),
     
'#default_value' => $node->new_field
     
);
    }
  }
}

function
test_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
 
$nodes = variable_get('test_node_types', node_get_types());

  foreach (
$nodes as $node_type) {
    if (
$node_type = $node->type) {
      switch (
$op) {
        case
'load':
         
$result = db_query("SELECT new_field FROM {test} WHERE nid = %d", $node->nid);
          while (
$row = db_fetch_object($result)) {
           
$node->new_field = $row->new_field;
          }
          break;
        case
'save': case 'update':
          if (
db_num_rows(db_query("SELECT nid FROM {test} WHERE nid = %d", $node->nid)) > 0) {
           
db_query("UPDATE {test} SET new_field = '%s' WHERE nid = %d", $node->new_field, $node->nid);
          } else {
           
db_query("INSERT INTO {test} (nid, new_field) VALUES (%d, '%s')", $node->nid, $node->new_field);
          }
          break;
      }
    }
  }
}
?>

<!-- node.tpl.php -->

  <div class="node<?php if ($sticky) { print " sticky"; } ?><?php if (!$status) { print " node-unpublished"; } ?>">
    <?php if ($picture) {
      print
$picture;
    }
?>

    <?php if ($page == 0) { ?><h2 class="title"><a href="<?php print $node_url?>"><?php print $title?></a></h2><?php }; ?>
    <span class="submitted"><?php print $submitted?></span>
    <span class="taxonomy"><?php print $terms?></span>
    <div class="content"><?php print $content?></div>
    <?php if ($node->new_field) { ?><div class="new_field"><?php print $node->new_field?></div><?php } ?>
    <?php if ($links) { ?><div class="links">&raquo; <?php print $links?></div><?php }; ?>
  </div>

uninstall the test module

seniormysterioso's picture

delete from cache;
delete from system where name = 'test'

Drupal Camp Seattle

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: