I am hoping that I can get some help/ideas on how to tackle this issue I am running into.

I am creating a directory for an office building. Within the building, there are a number of companies (tenants), and within those companies, there are employees. I would like to create a view that organizes those entries in a directory.

I have created a content type of "Tenant" with the following fields:

  • Tenant Name (title) - Tenant Name
  • Suite (field_suite) - Suite number in the building
  • Group (field_group) - A-Z to help group Tenants by letter

I have also created a content type of "Employee" with the following fields:

  • Employee Name (title) - Employee Name
  • Company (field_company) - List of companies in the building (dynamically populated by the published Tenants using Entity Reference View Widget

I would like to get some insight in how to create a View that will bring the two content types together under a single views, organized like this:

A
Acme Co (Suite 100)
- John Acme
- Jane Acme

Alpha Corp (Suite 150)
- John Alpha
- Jane Alpha

B
Beta Co (Suite 200)
- John Beta
- Jane Beta

Any help and insight would be much appreciated!

Thanks!

Comments

couturier’s picture

If there aren't too many tenants (fewer than 25, for example), you could create a separate View for each tenant and pull up the employees as the main View content and tacking the tenant description on as a header.

A better option is probably to use Panels with CTools to create commands that pull up content on one part of the page relative to another part of the page. I'm not experienced with this but know that it can be done efficiently.

A third option would be to create Modals that pop up when clicking on a certain tenant that shows the employees.

I'm not sure what the new capabilities would be within Drupal 8 which was released on November 19, 2015, but I do know that Views was incorporated into Core in D8 and that there are new options for placing content on the pages. I'd recommend experimenting a bit with D8 and seeing what might be done there.

Naoya Wada’s picture

couturier,

Thanks for your ideas! I really appreciate your taking the time to respond to my question.

However, I should have been more clear about the environment. This is meant for a non-interactive display. Meaning, I would be showcasing the information on a screen without input (no mouse, etc). Unfortunately we would have to showcase the information as static.

Any other thoughts that would help point me in the right direction given this information?

Thanks!

Sam Moore’s picture

On your Tenant content type, create an Entity Reference field with multiple values allowed, and use it to link to the employees of that Tenant. Now you have pointers on each tenant to the Employees who work there.
Visit each Tenant node and add the Employees in your new field.

In Views, create a View of Tenants.
In the Advanced section, create a Relationship with the Entity reference you created earlier - this brings the Employees of each Tenant company into scope.
Now add the Employee Name and other relevant employee fields to the View's output.
You can group by the Tenant name, to get it closer to your desired output.

If all of this is unfamiliar, see the documentation on Views. It's a vast and powerful system that takes considerable time to get your head around.

Naoya Wada’s picture

Sam,

Thank you for your reply! I will take a look and dive deeper into your suggestion. I appreciate your time and guidance.

Thanks!

Naoya