From ab65ff6b38aad3ea7f1361df44596fff86425062 Mon Sep 17 00:00:00 2001 From: Laury GvR Date: Fri, 29 Sep 2017 16:11:08 -0400 Subject: [PATCH] Connect the child contacts with the parent contacts Added new code on the contact list, and a filter in functions.php, which work together to look at all contacts which are a primary contact, and by those contacts list all the contacts associated with the same member which aren't primary contacts (the 'child' contacts). Also added most of the fields that were not already showing up for member contacts, on their list. --- functions.php | 23 +++ .../views/front/contacts/list.html | 161 ++++++++++++++++++ 2 files changed, 184 insertions(+) create mode 100644 glm-member-db-contacts/views/front/contacts/list.html diff --git a/functions.php b/functions.php index 0e9e88b..b944ef6 100644 --- a/functions.php +++ b/functions.php @@ -704,4 +704,27 @@ function template_chooser($template) } add_filter('template_include', 'template_chooser'); +add_filter('get_contacts_with_subs', function( $contacts ) { + foreach ($contacts as $contact) { + if ($contact["primary_contact"]["value"] == "1") { + $filtered_contacts[$contact["ref_dest"]] = $contact; + } + } + foreach ($contacts as $contact) { + $member_id = $contact["ref_dest"]; + if ($contact["primary_contact"]["value"] == "0" && !empty($filtered_contacts)) { + foreach ($filtered_contacts as $filtered_contact) { // <-- I especially don't like this one + if ($member_id == $filtered_contact["ref_dest"]) { + $filtered_contacts[$member_id]["subs"][] = $contact; + } + } + } + } + if (!empty($filtered_contacts)) { + return $filtered_contacts; + } else { + return false; + } +}); + ?> diff --git a/glm-member-db-contacts/views/front/contacts/list.html b/glm-member-db-contacts/views/front/contacts/list.html new file mode 100644 index 0000000..ccc5394 --- /dev/null +++ b/glm-member-db-contacts/views/front/contacts/list.html @@ -0,0 +1,161 @@ + + + + + Contacts List + + + + +{include file='front/contacts/header.html'} + +
+ + + + +
+
+
+ Text Search: +
+ {if $haveCounties} +
+ County Search: + +
+ {/if} +
+ +
+
+
+ +
+ +

Total found: {$numbContacts}  

+ + + {if $settings.list_show_search_alpha} + + {/if} + + + {if $paging} + +
+ Previous page + Next page +
+ showing {$start} through {$lastDisplayed} of {$filteredContactsFound} + {/if} + + + {$contacts_with_subs = apply_filters("get_contacts_with_subs", $contacts)} + + + {if $haveContacts} + + {foreach $contacts as $contact} + + {if $contact.active.value == 1} + +
+
+ {if $contact.image} +
+ {else} +
+ {/if} + +

+ {$contact.lname}, {$contact.fname} +

+
+
+ {if $contact.primary_contact.value == true} + + {if $contact.title}
{$contact.title}
{/if} + {if $contacts_with_subs !== false} + {foreach $contacts_with_subs as $contact_with_subs} + + {foreach $contact_with_subs["subs"] as $contact_sub} +
{$contact_sub["title"]}{$contact_sub["fname"]}
+ {/foreach} + + {/foreach} + {/if} + {/if} + {if $contact.ref_type.name} +
+ {if $contact.ref_dest_name} + {$contact.ref_dest_name} + {/if} +
+ {/if} + {if $contact.addr1}
{$contact.addr1}
{/if} + {if $contact.addr2}
{$contact.addr2}
{/if} + {if $contact.zip or $contact.city.name or $contact.state.name} +
+ {if $contact.city.name}{$contact.city.name},{/if} + {if $contact.state.name}{$contact.state.name}{/if} + {if $contact.zip}{$contact.zip}{/if} +
{/if} + {if $contact.county}
{$contact.county} County
{/if} + +
+
+ {if $contact.office_phone}
Work: {$contact.office_phone}
{/if} + {if $contact.home_phone}
Home: {$contact.home_phone}
{/if} + {if $contact.mobile_phone}
Mobile: {$contact.mobile_phone}
{/if} + {if $contact.alt_phone}
Alternate: {$contact.alt_phone}
{/if} + {if $contact.fax}
Fax: {$contact.fax}
{/if} + {if $contact.email}{/if} + {if $contact.alt_email}{/if} + {if $contact.url}{/if} +
+
+ {if $contact.org}
Organization: {$contact.org}
{/if} + {if $contact.descr}
Position & Responsibilities: {$contact.descr}
{/if} +
+
+
+ +
+ +
+
+
+ {/if} + {/foreach} + {else} + (no contacts listed) + {/if} + {if $paging} + +
+ Previous page + Next page +
+ showing {$start} through {$lastDisplayed} of {$filteredContactsFound} + {/if} + + +{include file='front/footer.html'} + + + \ No newline at end of file -- 2.17.1