From: Anthony Talarico Date: Thu, 6 Apr 2017 20:40:30 +0000 (-0400) Subject: splitting the list and detail views to make the filter application in both the detail... X-Git-Tag: v1.0.0^2~58 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8084cd2c73755e82f93db03fec2a4937f9fb50f9;p=WP-Plugins%2Fglm-member-db-fields.git splitting the list and detail views to make the filter application in both the detail and list pages more simple --- diff --git a/models/front/fields/detail.php b/models/front/fields/detail.php new file mode 100644 index 0000000..4f1c87d --- /dev/null +++ b/models/front/fields/detail.php @@ -0,0 +1,108 @@ +wpdb, $this->config); + $member_info_id = $member_info->getActiveInfoIdForMember($member_id); + $where = "ref_dest = $member_info_id"; + + $fields_data = new GlmDataFieldsCustomFieldsData($this->wpdb, $this->config); + $field_values = $fields_data->getList($where); + + foreach($field_values as $key=>$value){ + $field_id = $value['field_id']; + $field_value = $value['field_data']; + $sql = "SELECT field_name FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_fields WHERE id = $field_id;"; + $field_name = $wpdb->get_results($sql); + $field_name = $field_name[0]->field_name; + + if( $field_value ){ + $fields[$field_name] = $field_value; + } else if( $field_value === 'Yes'){ + $slash_price = true; + } + } + } + + // Compile template data + $templateData = array( + 'field_values' => $fields, + 'slash' + ); + error_reporting(E_ALL ^ E_NOTICE); + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/fields/list.html', + 'data' => $templateData, + 'settings' => $settings + ); + } + + public function cleanText($text){ + $text = str_replace(' ', ' ', $text); + $text = str_replace('–', '-', $text); + $text = str_replace(''', "'", $text); + $text = str_replace("\n", ' ', $text); + $text = str_replace("\r", '', $text); + return $text; + } +} + diff --git a/setup/frontHooks.php b/setup/frontHooks.php index fbb012c..0e66a9d 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -25,7 +25,15 @@ * * *** Also note that parameters will be in the context of the main front controller constructor. *** */ -add_filter('glm-member-db-front-members-detail-descriptionAfter', function($content, $id) { +add_filter('glm-member-db-front-members-detail-sidebar', function($content, $id) { + $eventData = do_shortcode('[glm-members-fields-detail member='.$id.', template="detail-sidemenu" order="title"]'); + $content .= $eventData; + return $content; + }, + 10, + 2 +); + add_filter('glm-member-db-front-members-list-info', function($content, $id) { $eventData = do_shortcode('[glm-members-fields-list member='.$id.', template="detail-sidemenu" order="title"]'); $content .= $eventData; return $content; diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 5a07009..f036484 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -87,6 +87,21 @@ */ $glmMembersFieldsShortcodes = array( + 'glm-members-fields-detail' => array( + 'plugin' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, + 'menu' => 'fields', + 'action' => 'detail', + 'table' => false, + 'attributes' => array( + 'type' => 'all', + 'order' => 'title', + 'member' => false, + 'template' => false, + 'limit' => null, + 'featured' => null, + 'current' => null, + ) + ), 'glm-members-fields-list' => array( 'plugin' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, 'menu' => 'fields', diff --git a/setup/validActions.php b/setup/validActions.php index 4df99c0..5e68202 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -69,6 +69,7 @@ $glmMembersFieldsAddOnValidActions = array( 'frontActions' => array( 'fields' => array( 'list' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, + 'detail' => GLM_MEMBERS_FIELDS_PLUGIN_SLUG, ), ) ); diff --git a/views/front/fields/detail.html b/views/front/fields/detail.html new file mode 100644 index 0000000..f406c07 --- /dev/null +++ b/views/front/fields/detail.html @@ -0,0 +1,8 @@ +{foreach $field_values as $key=>$value} +
+ {if $value !== 'Yes'} +
{$key}
+
{$value}
+ {/if} +
+{/foreach} \ No newline at end of file diff --git a/views/front/fields/list.html b/views/front/fields/list.html index 960573e..a817c93 100644 --- a/views/front/fields/list.html +++ b/views/front/fields/list.html @@ -2,9 +2,7 @@
{if $value !== 'Yes'}
{$key}
-
{$value}
{/if} -
{/foreach}