0

I'd like to view my block on pages where the content type = booking and where the address is node/add/booking (basically add, edit and view nodes), how can I accomplish this? So far my code only shows on pages where content type = booking (i.e. view and edit nodes).

<?php
// Change the type to the one you want to match on
$desired_type = 'booking';
if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
  $node = node_load(arg(1));
   return $node->type == $desired_type;
}

return FALSE;
?>
2

You can do it like this. It uses exactly the same principles as your existing if statement.

// Change the type to the one you want to match on
$desired_type = 'booking';
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $node = node_load(arg(1));
  return $node->type == $desired_type;
}
elseif (arg(0) == 'node' && arg(1) == 'add' && arg(2) == $desired_type) {
  return TRUE;
}
return FALSE;
2

Here you go:

<?php
$desired_type = 'booking';

if ($_SERVER['REQUEST_URI'] == '/node/add/booking') {return TRUE;} 

if ( arg(0) == 'node' && is_numeric(arg(1)) ) {
  $node = node_load(arg(1));
   return $node->type == $desired_type;
}

else {return FALSE;}
?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.