Updates on the search form
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 8 Jul 2013 18:48:55 +0000 (18:48 +0000)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 8 Jul 2013 18:48:55 +0000 (18:48 +0000)
Remove the go button
Take out the setting of form selects
Remove regions
work on adding to breadcrumbs which search your doing

Toolkit/Template/BreadCrumbs.php
libjs/pagefunctions.js
templates/template.html

index fb1035b..c884de1 100644 (file)
@@ -74,6 +74,60 @@ class Toolkit_Template_BreadCrumbs
                           && filter_var($_GET['photo_catid'], FILTER_VALIDATE_INT)
                );
 
+        $activityId = filter_var($_REQUEST['activityId'], FILTER_VALIDATE_INT);
+        $parkId     = filter_var($_REQUEST['parkId'], FILTER_VALIDATE_INT);
+        $countyId   = filter_var($_REQUEST['countyId'], FILTER_VALIDATE_INT);
+        $hasSearch  = ($activityId || $parkId || $countyId);
+
+        if ($hasSearch) {
+            // add search type Activity, Park or County
+            $catid = filter_var($_GET['catid'], FILTER_VALIDATE_INT);
+            // get activity or park
+            try {
+                $dbh = Toolkit_Database::getInstance();
+                if ($activityId) {
+                    $sql = "
+                    SELECT name
+                      FROM members.category
+                     WHERE category_id = :id";
+                    $stmt = $dbh->prepare($sql);
+                    $stmt->bindParam(':id', $activityId, PDO::PARAM_INT);
+                    $searchParam = $stmt->fetchColumn();
+                    $searchParam .= ' Activity';
+                } else if ($parkId) {
+                    $sql = "
+                    SELECT name
+                      FROM members.category
+                     WHERE category_id = :id";
+                    $stmt = $dbh->prepare($sql);
+                    $stmt->bindParam(':id', $parkId, PDO::PARAM_INT);
+                    $searchParam = $stmt->fetchColumn();
+                    $searchParam .= ' Park';
+                } else if ($countyId) {
+                    $sql = "
+                    SELECT county_name
+                      FROM members.county
+                     WHERE county_id = :id";
+                    $stmt = $dbh->prepare($sql);
+                    $stmt->bindParam(':id', $countyId, PDO::PARAM_INT);
+                    $searchParam = $stmt->fetchColumn();
+                    $searchParam .= ' County';
+                }
+                $stmt->execute();
+                array_unshift($stack, $searchParam);
+            } catch (PDOException $e) {
+                Toolkit_Common::handleError($e);
+            }
+            $seoUrl = Toolkit_Template_Page::getSeoUrl(
+                               $this->pageGateway,
+                               $catid
+                       );
+            // this should be after adding the search type
+            $page = $this->pageGateway->findNavItem($catid);
+            $anchor = '<a href="'.$seoUrl.'">'.$page['navigation_name'].'</a>';
+                       array_unshift($stack, $anchor);
+        }
+
                if ($hasPhotoGalleriesOnThisPage) {
                        if (!$catid = filter_var($_GET['catid'], FILTER_VALIDATE_INT)) {
                                throw new RuntimeException('Invalid catid');
@@ -120,7 +174,7 @@ class Toolkit_Template_BreadCrumbs
             }
                        $page  = $this->pageGateway->findNavItem($id);
                        $isShortcut = filter_var($_REQUEST['t'], FILTER_SANITIZE_STRING);
-                       if ($hasPhotoGalleriesOnThisPage) {
+                       if ($hasPhotoGalleriesOnThisPage || $hasSearch) {
                                //      Do Nothing
             } else {
                                array_unshift($stack, $page['navigation_name']);
index 82a0bd4..f2113b2 100755 (executable)
@@ -1,6 +1,17 @@
 $(document).ready(function() {
+    // setup the search form to submit onChange
+    $("#activity").change(function(){
+        $("#findTrail").submit();
+    });
+    $("#park").change(function(){
+        $("#findTrail").submit();
+    });
+    $("#county").change(function(){
+        $("#findTrail").submit();
+    });
+
        currentNav();
-       
+
        // Add Click Handlers for the tab buttons.
        //$("#trail_main_btn").click(function() {
        //      trailTabs(this);
@@ -30,21 +41,21 @@ function currentNav() {
 
 function trailTabs(clickedLink) {
        //alert(clickedLink.id);
-       
+
        // Clear all currents.
        //$("#trail_main_btn").removeClass('current');
        $("#trail_guide_btn").removeClass('current');
        $("#trail_facilities_btn").removeClass('current');
        $("#trail_directions_btn").removeClass('current');
        $("#trail_information_btn").removeClass('current');
-       
+
        // Hide all tab content.
        //$("#top_wrapper").css('display', 'none');
        $("#trail_guide").css('display', 'none');
        $("#trail_facilities").css('display', 'none');
        $("#trail_directions").css('display', 'none');
        $("#trail_information").css('display', 'none');
-       
+
        // Set this as current.
        if(clickedLink.id == "trail_guide_btn") {
                $("#trail_guide_btn").addClass('current');
@@ -59,4 +70,4 @@ function trailTabs(clickedLink) {
                $("#trail_information_btn").addClass('current');
                $("#trail_information").css('display', 'block');
        }
-}
\ No newline at end of file
+}
index 55a09a5..3f3ab3e 100755 (executable)
@@ -78,7 +78,7 @@
                             <option value="">Activity</option>
                             <?php foreach($t->activitySearch as $id => $label) {
                                 echo '<option
-                                value="'.$id.'"'.(($_REQUEST['activityId'] == $id)?' selected':'').'>
+                                value="'.$id.'">
                                 '.$label.'</option>';
                             }?>
                                                </select>
                             <option value="">Park</option>
                             <?php foreach($t->parkSearch as $id => $label) {
                                 echo '<option
-                                value="'.$id.'"'.(($_REQUEST['parkId'] == $id)?' selected':'').'>
-                                '.$label.'</option>';
-                            }?>
-                                               </select>
-                                               <select
-                            name="regionId"
-                            id="region"
-                            flexy:if="regionSearch">
-                            <option value="">Region</option>
-                            <?php foreach($t->regionSearch as $id => $label) {
-                                echo '<option
-                                value="'.$id.'"'.(($_REQUEST['regionId'] == $id)?' selected':'').'>
+                                value="'.$id.'">
                                 '.$label.'</option>';
                             }?>
                                                </select>
                             <option value="">County</option>
                             <?php foreach($t->countySearch as $id => $label) {
                                 echo '<option
-                                value="'.$id.'"'.(($_REQUEST['countyId'] == $id)?' selected':'').'>
+                                value="'.$id.'">
                                 '.$label.'</option>';
                             }?>
                                                </select>
-                                               <input type="submit" name="submit" value="submit">
                                        </form>
                                </div><!--/#findatrail-->
                                <div id="action">