I'm developing a new picture module in Drupal and I've got a little problem.

Each time I add or modify a node of my new module the function hook_form() is called. So both pages are powered by the same source code in hook_form(). But I want to display slightly different content on both pages, depending on if you are on "add node" or "edit node". Isn't there some kind of variable that tells me what page the user is looking at?

Thanks a lot in advance!

Comments

mixey’s picture

I stuck with the same problem... don't know how to determine in module which action is taken now add or edit node

mixey’s picture

I'm not sure if it is the best solution, but it worked for me:

function HOOK_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {
case 'prepare':
if (arg(1) == "add") {
print "ADD option";
}
break;

case 'validate':
if (!arg(1) == "edit") {
print "EDIT option";
}
break;
}
}

clemens.tolboom’s picture

Not sure if this isset( $node->nid) should do the trick? Just watching :-)

ideveloper’s picture

Thanks a lot, this solution works fine!