Change the look of drupal or node module

I am using hook_alter to modify forms in a custom PHP module. I started using the same approach by modifying the results page of the "node Add" form. However, this page is not a form, so I don't have a form id to connect to. It actually contains a login form, but it does not contain the elements that I am looking for.

Then I cloned the file called node.tpl.php and named 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 works.

However, here all my content seems to be flattened to a single line named $ content, so manipulating that becomes very difficult.

What approach should be taken in this situation?

+2


a source to share


2 answers


The default admin account always has uid 1 in the users table, so to do something for everyone but the admin you can do this:



// Bring the $user object into scope
global $user;

if ($user->uid != 1) {
  do something here...
}

      

0


a source


You can determine the properties of the current user by running:

global $user;
var_dump($user);

      

This will show you your account. So if you wanted to restrict something to a role, you would do:



if (in_array('administrator', $user->roles)) {
  // code
}

      

But I think you would be much better off using CCK and Content Permissions for field-level visibility control like this.

+1


a source







All Articles