splitting the list and detail views to make the filter application in both the detail...
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 6 Apr 2017 20:40:30 +0000 (16:40 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 6 Apr 2017 20:40:30 +0000 (16:40 -0400)
more simple

models/front/fields/detail.php [new file with mode: 0644]
setup/frontHooks.php
setup/shortcodes.php
setup/validActions.php
views/front/fields/detail.html [new file with mode: 0644]
views/front/fields/list.html

diff --git a/models/front/fields/detail.php b/models/front/fields/detail.php
new file mode 100644 (file)
index 0000000..4f1c87d
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+/**
+ * list.php
+ *
+ * This is the Members Fields Plugin model for the front list shortcode.
+ * Handles the default and searching of the fields. Then calls appropriate view
+ * files.
+ */
+require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFields.php';
+require_once GLM_MEMBERS_FIELDS_PLUGIN_CLASS_PATH . '/data/dataCustomFieldsData.php';
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php';
+
+/**
+ * GlmMembersFront_fields_detail
+ *
+ * @uses      GlmDataFields
+ * @package   GlmMemberFields
+ * @version   0.0.1
+ * @copyright Copyright (c) 2010 All rights reserved.
+ * @license   PHP Version 3.0 {@link http://www.php.net/license/3_0.txt}
+ */
+class GlmMembersFront_fields_detail extends GlmDataFieldsCustomFields
+{
+
+    /**
+     * modelAction
+     *
+     * @param bool $actionData Action Data passed to the modelAction
+     *
+     * @access public
+     * @return void
+     */
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    
+    public function modelAction( $actionData = false )
+    {
+        $member_id      = null;
+        $where          = '';
+        $order          = '';
+        $field_vals     = '';
+        $slash_price    = false;  
+
+        global $wpdb;
+        
+        // get the member id to pass to getList, set the where clause
+        if ( isset( $actionData['request']['member'] ) ) {
+            $member_id = $actionData['request']['member'] - 0;
+            $member_info    = new GlmDataMemberInfo($this->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('&nbsp;', ' ', $text);
+        $text = str_replace('&ndash;', '-', $text);
+        $text = str_replace('&#39;', "'", $text);
+        $text = str_replace("\n", ' ', $text);
+        $text = str_replace("\r", '', $text);
+        return $text;
+    }
+}
+
index fbb012c..0e66a9d 100644 (file)
  *
  *  *** 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;
index 5a07009..f036484 100644 (file)
  */
 
 $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',
index 4df99c0..5e68202 100644 (file)
@@ -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 (file)
index 0000000..f406c07
--- /dev/null
@@ -0,0 +1,8 @@
+{foreach $field_values as $key=>$value}
+<div class="glm-row field-container">
+   {if $value !== 'Yes'}
+        <div class="glm-small-6 glm-columns field-name">{$key}</div>
+        <div class="glm-small-6 glm-columns field-value">{$value}</div>
+   {/if}
+</div>
+{/foreach}
\ No newline at end of file
index 960573e..a817c93 100644 (file)
@@ -2,9 +2,7 @@
 <div class="glm-row field-container">
    {if $value !== 'Yes'}
         <div class="glm-small-6 glm-columns field-name">{$key}</div>
-
         <div class="glm-small-6 glm-columns field-value">{$value}</div>
    {/if}
-
 </div>
 {/foreach}