Tuesday, January 13, 2009

node_revisions concept digest

"...
Can I assume that the node_revisions record with the latest timestamp is the most current?

No. Drupal core does this and it can cause problems: http://drupal.org/node/300714

Or should I assume that the node_revisions record with the largest vid is the most current?
No.

If neither of the prior two how can I tell which node_revisions record is the most current for a node?
By the value of vid in the node table.

What is the node_revisions.log field used for? Mine are always blank?
This is the value of the log field on the node edit form.

Where do I set revision tracking in the UI? Do I do it on a per content-type basis? Globally? Other?
It is configured on the content-type settings page.

And finally, is there anything else I should know about working with the node_revisions using raw SQL?
Probably. You should have a good understanding of the hook_nodeapi function if you are planning on modifying nodes and directly manipulating the node_revisions table.
..."

Q from MikeSchinkel - December 24, 2007 - 21:48
A by imrook - September 7, 2008 - 18:27
[ref] http://drupal.org/node/203697

tables: node, node_revisions

node:
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| nid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| vid | int(10) unsigned | NO | UNI | 0 | |
| type | varchar(32) | NO | MUL | | |
| language | varchar(12) | NO | | | |
| title | varchar(255) | NO | MUL | | |
| uid | int(11) | NO | MUL | 0 | |
| status | int(11) | NO | MUL | 1 | |
| created | int(11) | NO | MUL | 0 | |
| changed | int(11) | NO | MUL | 0 | |
| comment | int(11) | NO | | 0 | |
| promote | int(11) | NO | MUL | 0 | |
| moderate | int(11) | NO | MUL | 0 | |
| sticky | int(11) | NO | | 0 | |
| tnid | int(10) unsigned | NO | MUL | 0 | |
| translate | int(11) | NO | MUL | 0 | |
+-----------+------------------+------+-----+---------+----------------+
15 rows in set (0.00 sec)



node_revisions:
+-----------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+----------------+
| nid | int(10) unsigned | NO | MUL | 0 | |
| vid | int(10) unsigned | NO | PRI | NULL | auto_increment |
| uid | int(11) | NO | MUL | 0 | |
| title | varchar(255) | NO | | | |
| body | longtext | NO | | NULL | |
| teaser | longtext | NO | | NULL | |
| log | longtext | NO | | NULL | |
| timestamp | int(11) | NO | | 0 | |
| format | int(11) | NO | | 0 | |
+-----------+------------------+------+-----+---------+----------------+
9 rows in set (0.00 sec)

Sunday, January 11, 2009

Often used API functions

$modulepath= drupal_get_path('module', 'nameofmodule');
drupal_add_css($modulepath. '/cssname.css');
drupal_add_js($modulepateh. '/jsname.css');

Drupal javascript namespace
Drupal.t()
Drupal.checkPlain()

Drupla php has no namespace???
t()
l()
check_plain()

Friday, January 9, 2009

Set the label of a field with t() function?

[Q] How to set the label of a field with t() function?

Cannot see "edit field/manage field"

[Symptom] Cannot see "edit field/manage field" after installing CCK
[sol] check "User management" -> Permission