1

I'm working on a project that collects information about a corporate client and then based on the information provided, connects that client with other companies that can help them with a specific need.

I have worked through the first half of the project to collect data conditionally based on the type of industry/operations the company is involved with using rules. Now i need to use the information collected and filter a view to find matching companies.

Essentially once a client submits their finalized application (a collection of different fields within a handful of content types), behind the scenes I need to figure out a way to filter a view of other companies with matching characteristics, then for each company that matches the filtered view, add a new node within a separate content type and then entity reference that node back to the finalized application for further input/editing. Here is a simplified visual:

Most of the fields being filtered are taxonomy references; however, some would be numeric inputs filtered by a less than, greater than, or equal to filter.


Financials Taxonomy: good financials; so so financials; challenged financials

Industry Taxonomy: technology, manufacturing, real estate, etc...

"Client A" node field answers in Clients content type:

  • good financials (financials taxonomy reference)
  • focused on technology (industry taxonomy reference)
  • 50 employees (numerical field)

Companies content type contains the following nodes:

  • Company A: likes only challenged financials; focused on manufacturing; works with companies <100 employees
  • Company B: likes only good financials; focused on technology; works with companies <500 employees
  • Company C: likes only challenged financials; focused on manufacturing; works with companies <25 employees
  • Company D: likes only good or challenged financials; focused on manufacturing; works with companies <100 employees

Once client A selects a field indicating the answers are finalized and the content type Clients is saved, I need to find a way to have the matching companies filtered based on client A's answers, and a new node for a different content type (content type called Partner Details) should be created for each matching company.

That content type would be called Partner Details and would consist of the following fields for each matching company:

  • entity references the client content type
  • entity references the matching company to the client
  • custom blah blah blah entered by rules that indicates why the match makes sense
  • contact information from the company content type
  • etc., etc...

So to sum up, client A answers the questions noted above within the client content type, then based on that information, the data within the Companies content type would be filtered - and for this example - two new nodes of Partner Detail content type would be created because nodes in the Companies content type matched the fields that Client A answered in Clients content type. Company B and Company D matched the criteria so they would be entity referenced by the two new Partner Details nodes created. This way, Client A could log in and see their matches and edit the matching partner details and view information about Company B or D based on their entity referenced nodes.


I have an intermediate understanding of views, panels and rules, but can't seem to figure out how i would do this behind the scenes once a user indicates the application is finalized. I also have an understanding of how to use rules to create new nodes and entity reference them. Hoping for a step by step example as detailed as you can provide. Any help is greatly appreciated. Thanks for bearing with my long winded explanation, hopefully that makes some sense.

(Finally, I had no idea what to title this question so if anyone has a better suggestion, let me know and I'll change it.)

1 Answer 1

1

You need the below rule to fire when the client's content type is saved.. And all relevant fields must exist in BOTH content types. It will talk your clients answers, feed them through a VBO, get the company NIDs that match and then loop through them to create Partner Details nodes.

  1. First, you need to have Views Bulk Operations (VBO) which will give a new rule action.. "Load a list of entity IDs from a VBO View". In this action, you can specify a VBO view and a list of arguments (taxonomy tids etc.) to send to the view using replacement patterns. The list of returned IDs is what you will use to create your "partner details".
  2. You need to create the VBO view by adding "Bulk operations: Content (Content)" as a field in a new view. The arguments sent from the rules action can be picked up by contextual filters using the "Provide Default: Raw Value from URL" setting. If I remember correctly, the first argument starts with path component 2.
  3. The results of the VBO should be limited to those nodes that match the arguments. Now we have a list in rules that we can use Loop to go over.
  4. Depending on needs, you can just create the new entities and reference the client and company nodes or do a two way reference so that the client and company nodes also reference each partner detail node.

The above is will do the taxonomy fine but for the integers, it's a bit more complicated since the contextual filter must match perfectly. For this, you can use the contextual filter: Global Null (which won't limit the results) and use Views Argument Substitutions to take the value from the contextual filter and use it in your views filters (the regular ones on the left). * * *!2 * * * (no spaces) if your global: null is the second contextual filter.

This is pretty limited but it could work. If you need it to only be 50-100 employees for example, on the company content type, have minimum and maximum integer fields and use "greater than" and "less than" filters in VBO view.

You should do quite a lot of testing on the VBO preview to make sure things work as expected. I really believe this is the only way to do this without writing a nasty amount of custom code. Good luck!

Your Answer

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

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