How to bring Related Module data in on Email Templates?

Alright, so I wrote myself a little guide on how to add in new modules on the Email Templates module. But what if the data I need is in a related module instead of the module itself?

We have a custom contacts module called ‘preps_contracted_reps’.

Related to this module is a module called ‘wn_writing_number’.

When I email these folks, I’d like to bring in the ‘wn_writing_number.title_c’ field.
In addition, I’d like to ask for any suggestions on something more complicated than that.

This relationship exists in our CRM:

The Rep His Number His upline’s number His upline’s contact page
Representative -> Writing Number -> Writing Number - Representative

My problem is that I need to retrieve the upline’s contact page information.

Right now, this is a one-to-many relationship. 1 Rep to Many Writing Numbers.

Here is what I know so far:

HOW TO ADD NEW MODULES TO EMAIL TEMPLATES DROPDOWN MENU:

  • Follow instructions found from here: https://sabalinfo.wordpress.com/2013/10/11/customizing-the-email-module/
  • (copied here for safekeeping)
    – modules/Emails/Email.php
    — around lines 500-515 in the ‘email2Send’ function, add this line inside the if statement
    ---- || $REQUEST[‘parent_type’] == ‘Opportunities’
    – modules/EmailTemplates/EditView.php
    — Add new option around line 300-320
    ----
    ---- “.$app_list_strings[‘moduleListSingular’][‘Cases’].”
    ----
    – modules/EmailTemplates/EmailTemplate.php
    — add new modules to $loopControl, $prefixes, substantiate new module class in both generateFieldDefsJS and generateFieldDefsJS2 functions
    ---- add line right inside function
    ---- $sales = new Opportunity();
    ---- Add line inside $loopControl array
    ---- ‘Opportunities’ => array(
    ---- ‘Opportunities’ => $sales,
    ---- ),
    ---- Add line inside $prefixes array
    -----‘Opportunities’ => 'opportunity
    ’,

This right here adds a new module, so problem #1 solved, any suggestions on how to resolve #2 and #3?

I’m going to continue to investigate, but wanted to know if anyone else had needed to do this?

Did you ever find a solution to this? I also need to pull in data from different modules in my email templates. Thanks!