0

I am trying to learn Drupal, and getting stuck every hour. I wish someone could walk me through this. I am trying to create a Employee-Company relationship. I have created a Company Content Type with just Name, Address and Telephone Numbers. And a Employee with Name and an Entity Reference to Company and multi-value Term Reference to skill set.

Now in my page skill/[whatever_the_skill_may_be] - I get a list of Employee. This happens automatically. Now I want to show the Company information along with each employee, but surprisingly can't seem to do this easily. I get the Company name which can be linked, but not the address or Telephone number.

Some of the pages I searched for the answer seem to suggest creating a View for this. I am not sure if I really need to, for such a simple requirement. But even if I do so, how do I override the default view of skill/[whatever_the_skill_may_be], and also the employee/[name-of-employee] page, where I would like to show the company information?

I hope I am not asking a stupid or very obvious question. Thanking u in advance,

2 Answers 2

1

Its simple, follow the steps.

  1. Create a view of employees.
  2. In the Format section show fields instead of content
  3. Add the fields, Employee Name, Skill, Company Name
  4. Add a Contextual Filter, Content: Has taxonomy term ID
    • Provide default value as Taxonomy term Id from URL
    • Select Specify validaion criteria
      • Select the validator Taxonomy term and choose your vocabulary - Skillset
      • In filter value type, select Term name converted to Term ID
  5. Add a relationship Entity Reference: Referenced Entity
  6. Now add the fields, Phone, Address, but make sure you are selecting the relationship that you added.
3
  • wolverine...how do I override the default pages? Commented Jun 21, 2014 at 7:44
  • @Nandini I've posted an answer which describes the best practice to do that, which is already provided by Views.
    – Elin Y.
    Commented Jun 21, 2014 at 7:58
  • You can't do it to the default page, but views by default provide one view to mimic the core page, that view will be named Taxonomy Term, enable that view and follow my answer from Step 5
    – msmani
    Commented Jun 21, 2014 at 8:00
0

You need Views to achieve that. The listing you are getting automatically is provided by Drupal core and it is meant only for simple listing of teasers of content.

Views module provides already an override for the core taxonomy listing. You just need to enable it and adjust for your needs.

To do that:

  1. Download and enable Views, if you haven't already done.
  2. Go to views administration at admin/structure/views
  3. Enable the view named Taxonomy Term and edit it.
  4. You need to add a relationship to the Company. To do that:
    • Expand the Advanced section
    • Add new relationship under Relationships and select Entity Reference: Referenced Entity with a description like A bridge to the Content entity that is referenced via FIELD_YOUR_REFERENCE_FIELD
    • Now you need to change the Teaser to Fields under Format.
    • You can now add the fields from the Employee content type AND Company content type which is referenced by the Employee.

Your Answer

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

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