The day are busy at Hoist. We are ready to launch our new work tool very soon (workshops are held next week with few spots left—let me know if you're interested).
Working on the user interface goodness I needed to execute some javascript immediately after a node has been posted in Drupal. The javascript should not be included on every node view, only the first. The nodeapi's 'insert' operation can't be used to include javascript because there is a redirect after it is processed and the 'view' operation can't tell if a node is brand new or not.
The solution I used is to set a session variable. It feels a little hackish, but it works great.
function yourmodule_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'insert') {
$_SESSION['yourmodule'][$node->nid] = $node->nid;
}
if ($op == 'view' && $_SESSION['yourmodule'][$node->nid]) {
// Insert call to drupal_add_js() here.
unset($_SESSION['yourmodule'][$node->nid]);
}
} This is the personal website of Andreas Haugstrup Pedersen: commentary on media, communication, culture and technology. Read more»
Add your comment