I´m experimenting with if/elseif, and can´t understand why it won´t work this in a Drupal 6 template.
This code works:
<?php
if ((arg(0) == 'node') && (arg(1) == 'add') || (arg(1) == 'edit')){
$node = node_load(array('nid' => arg(1)));
print '<h2>' . $title . '</h2>'; }
?>
In case I´m in node/add/whatever or node/nid/edit it shows the title variable wrapped into h2´s.
Now, I want to show something slightly different in case node/add and node/edit.
So, I´ve tried this:
<?php
if ((arg(0) == 'node') && (arg(1) == 'edit')) {
$node = node_load(array('nid' => arg(1)));
print '<h3>' . $title . '</h3>';
} elseif ((arg(0) == 'node') && (arg(1) == 'add')) {
$node = node_load(array('nid' => arg(1)));
print '<h2>' . $title . '</h2>'; }
} else {
echo ""; //it shows nothing
}
?>
And it won´t work (won´t show anything).
So, I´ve tried this:
<?php
if ((arg(0) == 'node') && (arg(1) == 'add')){
$node = node_load(array('nid' => arg(1)));
print '<h2>' . $title . '</h2>'; }
?>
<?php
if ((arg(0) == 'node') && (arg(1) == 'edit')){
$node = node_load(array('nid' => arg(1)));
print '<h3>' . $title . '</h3>';
}
?>
And in this case, it works only with node/add, but completely ignores node/edit.
What am I doing wrong?
Thanks for your advice!
The path for a node edit page is
node/[nid]/edit…you need to usearg(2)instead: