Added Files container to fronthooks markup
authorLaury GvR <laury@gaslightmedia.com>
Wed, 12 Apr 2017 13:17:36 +0000 (09:17 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Wed, 12 Apr 2017 13:19:25 +0000 (09:19 -0400)
The Files container div to be displayed on the member detail page
is now a part of the filter created in fronthooks to allow us to
only show it if there are indeed any files associated with this
member.

setup/frontHooks.php

index 7621148..c88e399 100644 (file)
@@ -46,11 +46,19 @@ add_filter('glm-member-db-front-members-detail-files', function( $content, $id)
     $file_path  =GLM_MEMBERS_PLUGIN_MEDIA_URL. "/files/";
     $sql        = "SELECT name, file_name,caption FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX ."files WHERE ref_dest = $id;";
     $results    = $this->wpdb->get_results($sql);
-
-    foreach($results as $result){
-        $caption = ($result->caption !== '' ? $result->caption : $result->name);
-        $file = "<a class='glm-file-detail' href='$file_path" . "$result->file_name" . "' target='_blank' >" .$caption .'</a>';
-        $content .= $file;
+    if ($results) {
+        $content .= "<div id='glm-member-detail-files-toggle' class='glm-member-detail-content-toggle'>Files</div>
+                     <div id='glm-member-detail-files-container' class='glm-member-detail-content-data small-12'>";
+        foreach($results as $result){
+            $caption = ($result->caption !== '' ? $result->caption : $result->name);
+            $file = "<a class='glm-file-detail' href='$file_path" . "$result->file_name" . "' target='_blank' >" .$caption .'</a>';
+            $content .= $file;
+        }
+        $content .= "<div class='glm-member-detail-sub-data-links row'>
+                        <a class='glm-member-detail-content-toggle'>Collapse</a>
+                        <a class='glm-member-detail-link-to-top'>Back to top</a>
+                    </div>";
+        $content .= "</div>";
     }
 
     return $content;