1

In D7 I am trying to display different information to different users with the same role. The 2 types of roles are 'Renter' and 'Landlord'. I've tried creating different views, but currently all renters and all landlords can see all renter info and all landlord info. I've tried Display Suite, Views, References, Entity References, all with no luck. :(

Ideally Larry Landlord would be able to see a list of all of his tenants (renters) with their addresses, rent amount, date of last rent payment, if the payment was processed, and if the rent is overdue. But currently he can see his info, and the info for the other landlords and renters.

Any thoughts?

Thanks!

After creating views and setting up an Entity Reference field, I am still having difficulty displaying the views I need. I'm trying to tie a renter (tenant) to a landlord, which would be a 1:1 relationship, and allow that one renter to see their history with their landlord. I am able to display all landlords and all renters, but when I try to create the 1:1 relationship that's where it falls apart. I may need another view, but I'm not sure how to connect the various views.

Any thoughts?

3
  • If I understand correctly, you can simply achieve that using the Views module Commented Oct 13, 2014 at 13:52
  • Thanks, Krishna. I am using the Views module, but I can't seems to filter a view per each user with the same role. I will have multiple Landlord roles, but want each landlord, upon logging in to see only his tenants.
    – URC Boston
    Commented Oct 13, 2014 at 14:05
  • Yes, it's possible with views. It seems you need to maintain relationship between users. (Say landlord and tenants). Commented Oct 13, 2014 at 14:07

1 Answer 1

0

If you don't already have one, create a View of Users to filter on.

In the Displays section of that view, add a new Display of type "Entity Reference" (where you would add one of Block, Page, etc.).

Now, you'll see in this new View Display the Format is called "Entity Reference List". Go to the settings for this formatter and add a field to search by (in this case, you'll want to use 'User: Name', most likely). Add a Filter Criteria here to only include Users of a specific Role (Tenants).

Now, go to Admin > Configuration > People > Account settings > Manage fields

Add an EntityReference field called "Tenants".

On the Field Settings page, change the Target type to User. Then change the Mode to "Views: filter by an EntityReference View". You'll see your list of "Tenants" here.

Still with me?

You'll want to make this field widget a Checkbox, probably, so that multiple values can be selected.

Okay, save on that screen and then on Field Edit page, change the number of accepted values to Unlimited. (it defaults to one).

Now, logged in as a Landlord, go to that Landlord's profile and select the Tenants off the checklist now visible on their profile.

You probably created a 'Page' by default with your Tenants (User) View, so now go to that page's View Display settings.

Add a Contextual Filter of User: UID. Set this to a 'Provide a Default Value' with type of "User ID of logged in User".

Now you can Utilize Fields on this Page View--Display content of "Field Tenants" and it will show whoever is selected in that field for the currently logged in user. You can tweak the settings here--if you want to show more information you can display them as "Rendered Entities" and then use any of the View modes for that user you've set up, you'll need to mess with "Multiple Field Settings as well to get it how you want, probably.

1
  • Thank you for this detailed answer! However, I am still having difficulty displaying the views I need. I'm trying to tie a renter (tenant) to a landlord, which would be a 1:1 relationship, and allow that one renter to see their history with their landlord. I am able to display all landlords and all renters, but when I try to create the 1:1 relationship that's where it falls apart. I may need another view, but I'm not sure how to connect the various views. Any thoughts?
    – URC Boston
    Commented Oct 23, 2014 at 9:18

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.