2

I'm building an intranet corporate site, and need to have users linked to departments. The easy way I see this to be done is to create a taxonomy vocabulary with list of departments, and then add custom field to user entity, linking it with corresponding department from departments vocabulary.

Now I want to add a "Person responsible" field to a custom content type (let's name it "Document"), which should be a list of users, organized by departments.

In future a need to use this field to control access to the document may arise.


So, the questions are:

  1. Is my method to link users to departments good enough, or are there better ways? (as this is now in development, I can change everything painlessly).
  2. What is the best way to make "Person responsible" field (a list of users, organized by departments).
  3. Does all this play well with possible future access control needs?
2

Add a "grouping" to the table settings if you want to group by department etc.

screenshot

(You would probably want to hide the department field in this case.)

Using taxonomy for user->department relationship sounds fine, and use Views to make all your lists of users/departments (group by):

  • Make a Vocabulary "Departments" and add some terms to it

    screenshot

  • Make a Person content type

  • Add a field to Person which is a taxonomy reference to the Department vocabulary

    screenshot

  • Download and enable the entityreference module

  • Modify the fields of the Vocabulary to add a field, which is an entity-reference to a Person node

  • Call it Person Responsible

    screenshot

  • Create some content to test with: Create some People, attach them to Departments, then edit the Departments (terms) to assign people responsible

  • Download and enable the Views module

  • Create a View of content, of type person. Add title+department fields

  • Add a relationship to the view "Content: Department"

  • Add the Person Responsible field to the view, using the relationship you just added

    screenshot

From discussion in IRC, I misunderstood the requirement around Document. It's simpler than described above. Just do:

  • Create Department vocabulary; add some terms

  • Create Person content type; add a taxonomy field referencing the Department vocabulary

  • Create the Document content type; add an entity reference field referencing nodes of type Person

  • Use Views to display, including "looking through" the entity reference

  • Thank you for your efforts. I've already done first 3 steps (with the only difference of not creating "Person" content type, but adding field referencing department directly to user entity). The hard part is the last step: make plain user list in that custom field to be organized by department. By now I know that a view could be wrapped into a field, so I will try that. – Shevchuk Jan 22 '13 at 13:27
  • Hello, and welcome on Drupal Answers. Please avoid splitting the answer over different posts. – kiamlaluno Jan 22 '13 at 14:19
  • thanks, @kiamlaluno. I played a bit with entity reference field referencing a view with user list, and now have a field with a list of users prefixed with corresponding department. It is better than just a plain list, but still could be better. Here is a mockup what I have and what I want: moqups.com/shevchuk/ePld40im In view preview I do have users grouped by departments (as set in format settings), but not in the actual field, have no idea why =( – Shevchuk Jan 23 '13 at 6:49
  • Hm, as far as I can see, grouping in select lists is not implemented by entity reference module yet T__T See drupal.org/node/1782324 Or are there still other options? – Shevchuk Jan 23 '13 at 7:20

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