Experimental project

This is a sandbox project, which contains experimental code for developer use only.

Mongor is an attempt to fill a "gap" in the EFQ Views module. EFQ Views are not compatible with views relationships because, by MongoDB's nature, JOINs are not possible. This is Mongo, after all, and not MySQL.

Mongor's solution to this is to pipe two existing views together to simulate a JOIN/relationship. If you take the output of one view display and use that as the contextual filter in another view — voila — you basically have a relationship.

Example

This is all a bit abstract, so here's an example: You have an e-commerce site and you'd like to show related blog post teasers on product pages. The posts and the products are related by tags. This view requires a relationship, but you're running Drupal on Mongo with EFQ Views.

If you think about it a different way, what you really have here is 2 views: (1) Get tags for the current product, and (2) Find blog posts with the same tag. You make the two views — a "source" and a "target," if you will.

The source view filters on the blog post content type and outputs the tid field of tags. The target view takes the tids as a contextual filter and outputs blog post teasers. You associate the view displays in the Mongor config, and then Mongor creates a block for you, with which you may do as you wish.

Creating a Mongo Relationship

These are the basic steps:

  1. Create a "source" view display that outputs a field that is useful as a contextual filter.
  2. Create a "target" view display that uses the field as a contextual filter.
  3. Go into the Mongor config and create a relationship by choosing your source and target view (more on Context later).
  4. In the block admin, find your newly generated block and have at.

But, why not just write a custom query?

You're right, that might be faster and, in the end, save you some headaches. But if you're someone who is comfortable with Views, but unfamiliar with writing custom Entity Field Queries, this module may be for you.

Project information

  • Created by majorrobot on , updated