<?php /* Template Name: List Pods */ $podname = isset($_GET['type']) ? $_GET['type'] : ""; $limit = isset($_GET['size']) ? $_GET['size'] : core_utilities::get_default_page_size(); $offset = isset($_GET['offset']) ? $_GET['offset'] : 0; $offset = $offset * $limit; if ($podname == '') { echo core_utilities::get_error_message("No Type Avaliable"); return; } $PodsAPI = pods_api(); $pods_info = $PodsAPI->load_pod(array('name' => $podname)); core_utilities::set_page_title("Listing - " . $pods_info['label']); get_header(); // CONTENT GOES HERE ?> <div class="row"> <div class="col-xs-12"> <div class="page-title-row"> <div class="row"> <div class="col-xs-12 col-sm-9"><h1 class="page-title">Listing - <?php echo $pods_info['label']; ?> </h1></div> <div class="col-xs-12 col-sm-3 text-right toolbar-top"> <?php echo pods_related::build_toolbar($podname, $pods_info['label'], false, null, $pods_info['options']['ui_filters'] != null); ?>
public static function gui_filter_pod() { $result = ""; $podname = isset($_GET['podname']) ? $_GET['podname'] : ""; if ($podname == "") { $result = "Op. gui_filter_pod -> Error: No Pod."; return $result; } $PodsAPI = pods_api(); $pods_info = null; try { $pods_info = $PodsAPI->load_pod(array('name' => $podname)); } catch (Exception $e) { $result = "Op. gui_filter_pod -> Error: Pod Not Exists."; return $result; } $offset = 0; $limit = core_utilities::get_default_page_size(); $params = array(); $where = array(); foreach ($_GET as $key => $value) { if ($key == "podname" || $key == "op" || strpos($key, "order-") !== FALSE) { continue; } $field = str_replace("to_control_", "", $key); $field = str_replace("control_", "", $field); $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($key, TRUE); $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($value, TRUE); $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($field, TRUE); $result .= "<br/>Op. gui_filter_pod -> Debug: " . var_export($pods_info['fields'][$field], TRUE); switch ($pods_info['fields'][$field]['type']) { case 'text': case 'website': case 'phone': case 'email': case 'password': case 'paragraph': case 'wysiwyg': case 'code': case 'slug': // Text Field $where[] = "t.{$field} like '%{$value}%'"; break; case 'pick': if ($field == 'author') { $where[] = "{$field}.display_name like '%{$value}%'"; } elseif ($pods_info['fields'][$field]['pick_object'] == "custom-simple") { $where[] = "{$field} = '{$value}'"; } else { $where[] = "{$field}.name like '%{$value}%'"; } break; case 'number': case 'currency': // Numaric Fields $comparison_operation = ">="; if (strpos($key, 'to_control_') !== false) { $comparison_operation = "<="; } $where[] = "t.{$field} {$comparison_operation} {$value}"; break; case 'datetime': case 'date': case 'time': // Date/Time Field $comparison_operation = ">="; if (strpos($key, 'to_control_') !== false) { $comparison_operation = "<="; } $where[] = "t.{$field} {$comparison_operation} '{$value}'"; break; default: $result .= "Op. gui_filter_pod -> Error: Not Supported Field Type."; return $result; } } $params["where"] = implode(" AND ", $where); // Handle Order By if (isset($_GET['order-orderby']) && $_GET['order-orderby'] != "") { $orderby = $_GET['order-orderby']; if (isset($_GET['order-type']) && $_GET['order-type'] != "") { $orderby .= "|" . $_GET['order-type']; } else { $orderby .= "|ASC"; } $params["orderby"] = $orderby; } $result = pods_related::build_table($pods_info, $offset, $limit, $params, FALSE, null, TRUE, TRUE); return $result; }