1

I am trying to create an employee directory using drupal 7. I have the following fields for each employee profile:

• Name
• Department
• Job Title
• Phone
• Email
• Optional photo
• A narrative-paragraph
• Note

Here is my requirement:

• Data (including photo) can be entered/updated by each employee using their login/password. • Data can also be entered by the administrator
• Employees cannot remove their name.
• Admins can see when information was updated.
• Listing that is searchable by name and department

I could not decide which is the best way - content type 'employee' or user role 'employee' with profile fields. If I create user as employee, how can I have the feature of the red information "updated" which we have in the content list (admin/content) when each content was updated?

1 Answer 1

1

I think you would be dealing with 'users' so using profile fields on user profiles would be your best shot. As a bonus, Drupal is well thought out and flexible enough to handle whatever kind of userbase you throw at it. Unless you want to re-invent the wheel in node hooks, I would shoot for profile fields and if you need to code up a custom module (or two), I can highly recommend entity api module to help you deal with profile field data.

The 'red' information you want (I assume) added to new content for example, (or any other possible variable) is easily done in templates. Usually based on conditionals and often (but not always) based on a bool variable of some kind.

For example, consider a 'flag' variable called $is_new. If $is_new isset (or !empty), either you send a conditional stylesheet, or set up a template to show that background in red text in black. As simple example here is a repost of recommended way to use if's in a template:

<?php if (!empty($is_new )): ?>
  <p><?php print $is_new ; ?></p>
<?php endif; ?>
 // You can use foreach statements for arrays you want to render
<?php foreach ($new_items as $item): ?>
  <p><?php print $item; ?></p>
<?php endforeach; ?>

As for the different views for different is totally a different matter, but happily is also built in natively via roles, permissions and content-access system.

Good-luck!

2
  • Are you saying the content type 'employee' is the best way? If I create that content type, I need one employe node to the respective user relationship. Am I right?
    – Sithu
    Sep 7, 2012 at 5:49
  • If I use user as employee, where could I get $is_new?
    – Sithu
    Sep 7, 2012 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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