Hi,

I'm looking for a functionality to compare 2 entities selected from a list/table (view)

I need some guidelines about how to:

A. allow the user to select the items (entities from a view)

B. display those entities side by side for comparison

If anyone can point me in the right direction, that would be appreciated

(Drupal 9)

Comments

wombatbuddy’s picture

It sounds like you need a custom module with JS. 

The way without a custom code:

1. Create the view and select the Grid format.  In the Grid options set two columns.
2. Add two exposed filters, one is needed that a user can select first entity for comparision and the secod is for the second entity. In the example below, I created the filters for Title.
3. Open the "Rearrange filter criteria" dialog and create the new filter group for "Or" operators.

The screenshots of the example:
1. https://www.drupal.org/files/entities_comparision-1.png
2. https://www.drupal.org/files/entities_comparision-2.png
3. https://www.drupal.org/files/entities_comparision-3.png
4. https://www.drupal.org/files/entities_comparision-4.png
5. https://www.drupal.org/files/entities_comparision-5.png

amirn’s picture

thanks for your idea.

How do I select the 2 entities to be compared from my table (or grid)?  is that requires JS?

wombatbuddy’s picture

Also, you may look at the Entity Browser module. What is the real use case?

amirn’s picture

A listing page, which allows the user to select items to be compared from the entire listing (listing would be grid, list or table format)

something like this: https://www.shopping.com/search.html?keyword=phone   ('add to compare' check, and a 'compare' button)

wombatbuddy’s picture

You may try the Entity comparison module.

amirn’s picture

not sure how I've missed this module :/

seems to be very close to what I need.

Thanks!