From e97224c0d8e3a8719c9cedbba0778c4af33cd760 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 25 Feb 2016 14:28:24 -0500 Subject: [PATCH] Working on search form Search for categories working. Hold the category search for in search field. --- models/front/events/list.php | 97 +++++++++++++++++++++--------- views/front/events/dashboard.html | 46 +++++--------- views/front/events/list.html | 8 +-- views/front/events/searchForm.html | 19 +++--- views/front/events/shortCuts.html | 4 +- 5 files changed, 98 insertions(+), 76 deletions(-) diff --git a/models/front/events/list.php b/models/front/events/list.php index a46af87..9c10e7f 100644 --- a/models/front/events/list.php +++ b/models/front/events/list.php @@ -44,147 +44,167 @@ class GlmMembersFront_events_list extends GlmDataEvents private function getCategories() { return array( - array( + 1 => array( 'id' => 1, 'name' => 'Arts & Crafts' ), - array( + 2 => array( 'id' => 2, 'name' => 'Arts/Cultural/Live Theatre' ), - array( + 3 => array( 'id' => 3, 'name' => 'Beer/Wine Focus' ), - array( + 4 => array( 'id' => 4, 'name' => 'Concerts/Live Music' ), - array( + 5 => array( 'id' => 5, 'name' => 'Educational' ), - array( + 6 => array( 'id' => 6, 'name' => 'Festivals/Fairs/Parades' ), - array( + 7 => array( 'id' => 7, 'name' => 'Outdoor/Nature' ), - array( + 8 => array( 'id' => 8, 'name' => 'Special Event' ), - array( + 9 => array( 'id' => 9, 'name' => 'Sports' ), ); } - private function getModelEventsData() + private function getModelEventsData($categoryId = null) { - return array( + $events = array( array( + 'id' => 1, 'title' => '20th Annual Garage Sale Art fair', 'starting' => '02/27/2016', 'ending' => '02/27/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts & Crafts' + 'category' => 1 ), array( + 'id' => 2, 'title' => 'ARTbreak: Talk: The Art of Collaboration with artists Vicki VanAmeyden and Ginger Owen', 'starting' => '03/01/2016', 'ending' => '03/01/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts & Crafts' + 'category' => 1 ), array( + 'id' => 3, 'title' => 'Easter Craft & Vendor Show', 'starting' => '03/26/2016', 'ending' => '03/26/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts & Crafts' + 'category' => 1 ), array( + 'id' => 4, 'title' => 'Henderson Castle Tours', 'starting' => '05/11/2016', 'ending' => '05/11/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts/Cultural/Live Theatre' + 'category' => 2 ), array( + 'id' => 5, 'title' => 'Colour Correction: British and American Screenprints, 1967-75', 'starting' => '06/11/2015', 'ending' => '06/10/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts/Cultural/Live Theatre' + 'category' => 2 ), array( + 'id' => 6, 'title' => 'Suspended! Sculpture from ArtPrize 2015', 'starting' => '12/12/2016', 'ending' => '12/13/2016', 'description' => '

Test event description text here!

', - 'category' => 'Arts/Cultural/Live Theatre' + 'category' => 2 ), array( + 'id' => 7, 'title' => '"Tasting on the Town"', 'starting' => '04/21/2016', 'ending' => '04/21/2016', 'description' => '

Test event description text here!

', - 'category' => 'Beer/Wine Focus' + 'category' => 3 ), array( + 'id' => 8, 'title' => 'Patrick Henry Beer Collectibles Show', 'starting' => '05/14/2016', 'ending' => '05/14/2016', 'description' => '

Test event description text here!

', - 'category' => 'Beer/Wine Focus' + 'category' => 3 ), array( + 'id' => 9, 'title' => '"Tasting on the Town"', 'starting' => '05/20/2016', 'ending' => '05/20/2016', 'description' => '

Test event description text here!

', - 'category' => 'Beer/Wine Focus' + 'category' => 3 ), array( + 'id' => 10, 'title' => 'Owl Prowl: Barred Owls', 'starting' => '02/25/2016', 'ending' => '02/25/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ), array( + 'id' => 11, 'title' => 'Owls of Michigan', 'starting' => '02/28/2016', 'ending' => '02/28/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ), array( + 'id' => 12, 'title' => 'Bird Sanctuary Resource Center Re-Opening', 'starting' => '02/29/2016', 'ending' => '02/29/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ), array( + 'id' => 13, 'title' => 'Lead Day Hike', 'starting' => '02/29/2016', 'ending' => '02/29/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ), array( + 'id' => 14, 'title' => 'Project Snowstorm: Snowy Owls in Michigan', 'starting' => '03/01/2016', 'ending' => '03/01/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ) ); + if ($categoryId) { + return array_filter($events, function($data) use($categoryId) { + return ($data['category'] == $categoryId) ? 1 : 0; + }); + } + return $events; } private function getModelEventData() @@ -194,7 +214,7 @@ class GlmMembersFront_events_list extends GlmDataEvents 'starting' => '02/25/2016', 'ending' => '02/25/2016', 'description' => '

Test event description text here!

', - 'category' => 'Outdoor/Nature' + 'category' => 7 ); } @@ -208,23 +228,30 @@ class GlmMembersFront_events_list extends GlmDataEvents */ public function modelAction($actionData = false) { + $categoryId = null; $action = ''; $settings = $events = $event = array(); if ($eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) { $search = true; $action = 'event-detail'; } + if ($categoryId = filter_var($_REQUEST['category'], FILTER_VALIDATE_INT)) { + $search = true; + $action = 'event-list'; + } if ($search = filter_var($_REQUEST['search'], FILTER_VALIDATE_INT)) { $search = true; $action = 'event-list'; } + $categories = $this->getCategories(); + switch ($action) { case 'event-detail': - $event = $this->getModelEventData(); + $event = $this->getModelEventData($eventId); break; case 'event-list': - $events = $this->getModelEventsData(); + $events = $this->getModelEventsData($categoryId); $view = 'list.html'; break; default: @@ -232,18 +259,28 @@ class GlmMembersFront_events_list extends GlmDataEvents // filter out the events $events = $this->getModelEventsData(); $view = 'dashboard.html'; + $categoryEvents = array(); + foreach ( $categories as $cat ) { + $catEvents = array_filter( $events, function($data) use($cat) { + return ($data['category'] == $cat['id']) ? 1 : 0; + } ); + if ( !empty($catEvents) ) { + $categoryEvents[$cat['id']] = $catEvents; + } + } break; } - $categories = $this->getCategories(); // Compile template data $templateData = array( 'siteBaseUrl' => GLM_MEMBERS_SITE_BASE_URL, + 'categoryId' => $categoryId, 'categories' => $categories, 'events' => $events, - 'event' => $event + 'event' => $event, + 'catEvents' => $categoryEvents ); return array( diff --git a/views/front/events/dashboard.html b/views/front/events/dashboard.html index 0dcead7..4fdb966 100644 --- a/views/front/events/dashboard.html +++ b/views/front/events/dashboard.html @@ -1,41 +1,23 @@ -

Dashboard

+

Dashboard

-
{include file='front/events/searchForm.html'} -
-
{include file='front/events/shortCuts.html'} -
-
-
    -
  • Arts & Crafts
  • -
  • Event title and date
  • -
-
-
-
    -
  • Arts/Cultural Events
  • -
  • Event title and date
  • -
-
-
-
    -
  • Beer/Wine Focus
  • -
  • Event title and date
  • -
-
-
-
    -
  • Concert/Live Music
  • -
  • Event title and date
  • -
-
-
+ {foreach $catEvents as $catid => $category} +
    -
  • Educational
  • -
  • Event title and date
  • +
  • {$categories.{$catid}.name}
  • + {foreach $category as $event} + {if $event@iteration == 4} + {break} + {/if} +
  • {$event.title}
  • + {/foreach}
+ {if $category@iteration is div by 2} +
+ {/if} + {/foreach}
diff --git a/views/front/events/list.html b/views/front/events/list.html index 2e6a83f..d046609 100644 --- a/views/front/events/list.html +++ b/views/front/events/list.html @@ -1,11 +1,7 @@

Event List

-
{include file='front/events/searchForm.html'} -
-
{include file='front/events/shortCuts.html'} -
{foreach $events as $event} @@ -13,8 +9,8 @@
{$event.starting}
- {$event.category}
- {$event.title} + {$categories[$event.category].name}
+ {$event.title}

diff --git a/views/front/events/searchForm.html b/views/front/events/searchForm.html index 09526b0..0fbaab3 100644 --- a/views/front/events/searchForm.html +++ b/views/front/events/searchForm.html @@ -1,43 +1,48 @@ +

Find An Event

-
+
- +
-
+
-
+
-
+
- +
+
diff --git a/views/front/events/shortCuts.html b/views/front/events/shortCuts.html index 08d4ab9..1304f19 100644 --- a/views/front/events/shortCuts.html +++ b/views/front/events/shortCuts.html @@ -1,7 +1,9 @@ + -- 2.17.1