Make ref_type and ref_dest variable, passed by the filters, adjusting urls as needed
authorLaury GvR <laury@gaslightmedia.com>
Thu, 20 Sep 2018 19:13:01 +0000 (15:13 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Thu, 20 Sep 2018 19:13:01 +0000 (15:13 -0400)
models/admin/newDashboard/index.php
views/admin/newDashboard/components/list.html

index e7b8f76..baf10ad 100644 (file)
@@ -248,9 +248,10 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
     }
 
     public function queryWidgetLists( &$widgetData = false ) {
+        
         foreach ( $widgetData as &$widgetComponent ) {
-            echo "<br>";
-            var_dump($widgetComponent);
+            //echo "<br>";
+            //var_dump($widgetComponent);
             if ( $widgetComponent['component'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) {
                 
                 if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) {
@@ -261,6 +262,16 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers
                 $resultsQuery = "SELECT " . $widgetComponent['fields'] . " FROM " . $widgetComponent['table'] . " WHERE " . $where . " LIMIT 5;";
                 $widgetComponent['sql'] = $resultsQuery;
                 $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery);
+
+                if ( isset($widgetComponent['listItems']) ) {
+                    foreach ( $widgetComponent['listItems'] as &$listItem ) {
+                        if ( isset($listItem->ref_type) ) {
+                            // Get the ref type from the config array - has to be forced lowercase due to inconsistency 
+                            // in url vs config array reference to ref_type (e.g. member vs Member, and member vs members)
+                            $listItem->ref_type = strtolower($this->config['ref_type'][$listItem->ref_type]);
+                        }
+                    }
+                }
                 $countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";";
                 $widgetComponent['count'] = $this->wpdb->get_var($countQuery);
 
index 42dfb39..f3ac0f9 100644 (file)
@@ -1,9 +1,8 @@
-<br>List component was called
 <div class="{$widgetField}-list list-header"> {$widgetField.title} <a href="#">{$widgetField.count}</a> </div>
 <ul class="collection">
 {foreach $widgetField['listItems'] as $listItem}
     <li class="collection-item" style="line-height: 1;padding : 5px 15px;">
-        <a href="{$widgetField.resultUrl}?member={$listItem->ref_dest}?packageID={$listItem->id}">
+        <a href='{$widgetField.resultUrl}{if isset($listItem->ref_dest) && isset($listItem->ref_type)}&{$listItem->ref_type}={$listItem->ref_dest}{/if}&{$widgetField.entityID}={$listItem->id}'>
             {$listItem->title}
         </a>
     </li>