Central NJ Drupal meetup Wed, March 2, 7 pm

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
pwolanin's picture
Start: 
2011-03-02 19:00 - 21:00 America/New_York
Organizers: 
Event type: 
User group meeting

Location: Institute for Advanced Study, Bloomberg Hall, Room 201 (Physics Library)

Topics:

  • Discussion of Drupal books and documentation. What have you used? What was most helpful?
  • Mutal assistance with sites, modules, themes, and other Drupal-related stuff
  • Going to Drupalcon? What sessions look most interesting?

Hosted by the Institute for Advanced Study Computing Department.

Directions: There is a map of the IAS campus on this page - http://www.ias.edu/about/directions.

Bloomberg Hall is building 4 on the map, next to Parking Lot A. Parking is free and generally there are plenty of spaces. We will meet in the Physics Library, Room 201.

Comments

Looking forward to tomorrow's meetup

bg1's picture

I am a ASP developer (actually more of a database/SQL developer) that is trying to get my arms around Drupal. I am hoping it will be possible to come away from tomorrow with a few specific examples of developing modules in Drupal 7.

In particular, I would like to see an example of a very, very simple Drupal 7 module that retrieves data from the database using a SQL statement, structures it as a form that goes to the client and then receives the update data and updates the database using another SQL statement.

If possible, I would then like to see a version of the same module using jQuery.

Finally, I would like to see how close one could come to the same solution using existing contributor modules (e.g. View, etc.).

Looking forward to meeting you all tomorrow.

Bill Graham

I would like to see some specific examples too

KunQian's picture

These seems are good examples to start with. Can I also see an example of how to theme a form?

Kun Qian

example.module for Drupal 7

pwolanin's picture

We discussed the Drupal 7 basics of writing a module to get data in and out of SQL. See also http://drupal.org/project/examples

example.info

name = Example
core = 7.x

example.module:

<?php
function example_menu() {
 
$items = array();
 
$items['example-page'] = array(
   
'title' => 'My page',
   
'page callback' => 'example_page',
   
'access callback' => TRUE,
  );
 
$items['example-data/%example_data/edit'] = array(
   
'title' => 'Edit data',
   
'page callback' => 'drupal_get_form',
   
'page arguments' => array('example_page_edit', 1),
   
'access callback' => TRUE,
  ); 
  return
$items;
}

function
example_data_load($nid) {
  if (!
is_numeric($nid)) {
    return
FALSE;
  }
  return
node_load($nid);
}

function
example_page_edit($form, &$form_state, $node) {
 
$form['node'] = array(
   
'#type' => 'value',
   
'#value' => $node,
  );
 
$form['title'] = array(
   
'#title' => t('New content title'),
   
'#description' => t('help goes here'),
   
'#type' => 'textfield',
   
'#default_value' => $node->title,
  );
 
$form['submit'] = array(
   
'#type' => 'submit',
   
'#value' => t('Submit'),
  );
  return
$form;
}

function
example_page_edit_validate($form, &$form_state) {
  if (
strlen($form_state['values']['title']) == 0) {
   
form_set_error('title', t('title cannot be empty'));
  }
}

function
example_page_edit_submit($form, &$form_state) {
 
$node = $form_state['values']['node'];
 
$node->title = $form_state['values']['title'];
 
node_save($node);
 
drupal_set_message('Saved the node');
 
$form_state['redirect'] = "node/{$node->nid}";
}

function
example_page() {
 
$result = db_query("SELECT n.title, n.uid, n.nid, u.name FROM {node} n INNER JOIN {users} u ON n.uid = u.uid WHERE n.status = 1");
 
$rows = array();
 
$headers = array('title', 'owner', 'edit');
  foreach (
$result as $node) {
   
$rows[] = array(check_plain($node->title), l($node->name, 'user/' . $node->uid), l(t('edit'), "example-data/{$node->nid}/edit"));
  }
 
$content['table'] = array(
   
'#theme' => 'table',
   
'#header' => $headers,
   
'#rows' => $rows,
  );
 
 
$content['hello'] = array(
   
'#markup' => '<h3>Hello world</h3>'
 
);
  return
$content;
}
?>

Thanks for the help last week

bg1's picture

Thanks to Peter and David for building a working module example working with databases. Thanks to everyone else for your patience since I realize my questions took almost the entire evening went to my questions.

Bill

Thursday next month

pwolanin's picture

FYI, we talked baout moving the schedule from Wed to Thur to see if that works better for people - I know at least 3 people locally who want to come but can't do Wed.

Yes,

fnikola's picture

Thursday works better for me

thursday is better for me as

tuphill's picture

thursday is better for me as well, I might actually get to see the end of the meeting for once.

Thursday

Lantz's picture

Sounds good to me too.

THU is great :-)

ksinha's picture

THU is great :-)

Thiusdays are better for me too...

ijf8090's picture

Am looking forward to finally getting one of these meeting.....

New York City

Group notifications

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

Hot content this week