What is new in Drupal 7

User experience

The design process can see at http://www.d7ux.org/

Drupal 7 UX design principles:

1. Make the most frequent tasks easy and less frequent tasks achievable.

2. Design for the 80%

3. Privilege the Content Creator

4. Make the default settings smart

Learned from D7 AI:

Less clicks is not nessarlly better.

Few options show = more decision made.

Order by frequency use

Dashboard module provide the simple way to organizing administrative tasks and tracking information within your site.

Database layer

New database API

1. New in D7 is the placeholder and placeholder array

$node = db_query(“SELECT * FROM {node} WHERE nid = :nid“, array(‘:nid’ => $nid))->fetchObject();

$title = db_query(“SELECT title FROM {node} WHERE nid = :nid“, array(‘:nid’ => $nid))->fetchField();

2. New result set loop functions

$result = db_query(“SELECT nid, title FROM {node}”);

foreach ($result as $record) {
$record = $result->fetch();            // Use the default fetch mode.
//$record = $result->fetchObject();  // Fetch as a stdClass object.
//$record = $result->fetchAssoc();   // Fetch as an associative array.
}

see more: http://drupal.org/node/310072

3. Dynamic queries

This is the big change in D7, see from http://drupal.org/node/310075

Support for master/slave replication

$result = db_query(“SELECT nid, title FROM {node}”, array(), array(
‘target’ => ‘slave’,
‘fetch’ => PDO::FETCH_ASSOC,
));

Support for Transactions

A function simply calls “$txn = db_transaction();” as its first (or nearly first) operation to make itself transactional.

Nosql (Mongodb) support

D7 has a mongodb module provide the mongodb API.

Other

Default to InnoDB engine

Semantic Web support

Support RDF

More

More secure password system, MD5 is no longer used.

More can see from http://drupal.org/about/new-in-drupal-7

Drupal Views PHP Code Validator

Views is one of the best module of Drupal. It provide a way to map the data in the mysql database to the web interface. You can do that even without writing any SQL query, just some clicks. I do not want to cover all the aspet of Views, but only to show how to restrict the Veiws result based on Arguments.

Arguments are parts of URL, may be a node id in /node/xxxx, or user id in /user/xxxx. Views provide some build-in arguments: See Views arguments. You can restrict the views by Node type, User ID, Term ID, etc. But these build-in features can not meet all of our requirement.

So we can use PHP Code Validator.

For example, I want to show the view only in the node where a CCK field eqs 1. And only show in the content type blog.

$nid = $argument;
$node = node_load($nid);
return ($node->type == ‘blog’ && $node->field_Myfield_type[0]['value'] == 1);

Put the php code block in the views argument, then you will find the result.

The nodejs growing very fast recently. New library or framework added to nodejs  almost everyday, since it is very easy to build a nodejs based module and javascript is used very widely.

I have done the A/B testing of nodeJS vs Erlang mochiweb, Erlang misultin, Nginx static page on my poor VM machine, and got the following result:

Nodejs helloworld:                     724 qps

Erlang mochiweb helloworld:     430 qps

Erlang misultin helloworld:         690 qps

Nginx static page:                    1045 qps

You can see that nodeJS is bloody fast thanks to the good performance of V8 JavaScript engine.

Talk about server side javascript, you should say Rhino, but nodejs is 20x faster than Rhino. NodeJS is stable, and not seen a bug of the code, like Nginx. You can build asynchronous system based on nodeJS and drop Tornado. What is important is that you can reuse your code both on client side and server side.

NodeJS is good at heavy IO usage, but not heavy CPU usage. And you should not change your current web system to nodeJS since it is too young.You can build your JSON interface by NodeJS, construct JSON from data fetched from database or remote web service, output the JSON format result.

Nodejs library:

npm — A node package manager that uses CommonJS-compatible package.json files, written in asynchronous JavaScript.

Express — A robust feature rich web development framework inspired by Sinatra

nodemachine — A port of WebMachine to Node.js

Connect — A  middleware framework for node

Socket.io — WebSocket-compatible server and client with fallback for legacy browsers

node-mysql — A node.js module implementing the MySQL protocol

redis2json — Easily loads data from Redis into structured JS object

See more:

https://github.com/joyent/node/wiki/modules