In the past I have used the Similar by terms module, It provides an amazing feature to display the related content in a block view which can be placed in a node view to see similar content to that node. Here similarity is subjected to the taxonomy terms only.

Recently I came across the Similar By References module, This module is an adaptation of the Similar By Terms module, but using an entity reference field instead of just taxonomy terms to determine similarity. For instance, if the node you are viewing has a reference to an entity, other nodes that reference the same entity will be listed as ‘Similar’ content. This module uses Views to create its database queries and display its results so that you can define what fields to show, additional sorting, filters, displays, etc.

Here I am trying to show an example for this, this needs installation of Drupal Entity API, Entity reference and Similar By References modules.

Below, there are 2 content types Garden and Plant, The Plant node has an entity reference field named as similarity pointing to a Garden node.

List of garden nodesPlant nodes

Once all the nodes are created, then navigate to Views administrator page admin/structure/views. There will be a view titled with Similar By References.

Similar by reference view

Here a small configuration setting has to be done for Similar By References view. Generally it is recommended to create a clone of the view and perform the custom changes. As it is an example I have made the changes to the master view itself.

Below are the steps for configuration which I am doing for this example, it may vary a bit according to the requirements:
1. Edit the View.
2. In the Contextual Filters section, there should be one already present named as Similar By References: Entityreferences in Content.

Contextual filter

3. Click on that, come down to the section where it says Similarity by References, Limit similarity to references from these fields *.
4. Check the entity referencing field, in this case it is Similarity (field_similarity).

Reference selection in view
5. Apply and Save the view.

This is a block view, so it should be under blocks unassigned portion, configure the block to display it at the required region, Here this has been placed at 1st sidebar.

That’s it, By now the block containing the similar nodes should appear in the 1st sidebar of the plant node if it has a reference to a garden node, which is also referred by other plant nodes.

Lotus node

mango node

The part which may makes it more popular is it’s outreach. As it is making this with an entity reference and now most of the things in Drupal are entities, so this can be used at most places where some information about similar content is needed.

Please feel free to add your suggestions, comments. Everything is more than welcomed.