drupalhookdrupal-alter

drupal module alter view or node


I have been using hook_alter to modify forms in a custom PHP module. I started to take the same approach modifying the result page of "node add" form. However this page is not a form so I don't have a form ID to hook on to. Actually it contains a login form, but that does not contain the elements that I am looking for.

Next I cloned the node.tpl.php file called and called it node-my-content-type.tpl.php. If I add "hello world" to this page, the phrase is displayed at the top, so I know it is working.

However, here all my content seems to be flattened to a single string called $content, so manipulating this becomes very difficult.

What approach should I use in this situation?


Solution

  • The default admin account always has the uid of 1 in the users table, so to do something for everyone except the admin, you could do this:

    // Bring the $user object into scope
    global $user;
    
    if ($user->uid != 1) {
      do something here...
    }