Working on search form
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Feb 2016 19:28:24 +0000 (14:28 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 25 Feb 2016 19:28:24 +0000 (14:28 -0500)
Search for categories working.
Hold the category search for in search field.

models/front/events/list.php
views/front/events/dashboard.html
views/front/events/list.html
views/front/events/searchForm.html
views/front/events/shortCuts.html

index a46af87..9c10e7f 100644 (file)
@@ -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' => '<p>Test event description text here!</p>',
-                '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' => '<p>Test event description text here!</p>',
-                'category'    => 'Arts & Crafts'
+                'category'    => 1
             ),
             array(
+                'id'          => 3,
                 'title'       => 'Easter Craft & Vendor Show',
                 'starting'    => '03/26/2016',
                 'ending'      => '03/26/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Arts & Crafts'
+                'category'    => 1
             ),
             array(
+                'id'          => 4,
                 'title'       => 'Henderson Castle Tours',
                 'starting'    => '05/11/2016',
                 'ending'      => '05/11/2016',
                 'description' => '<p>Test event description text here!</p>',
-                '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' => '<p>Test event description text here!</p>',
-                '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' => '<p>Test event description text here!</p>',
-                'category'    => 'Arts/Cultural/Live Theatre'
+                'category'    => 2
             ),
             array(
+                'id'          => 7,
                 'title'       => '"Tasting on the Town"',
                 'starting'    => '04/21/2016',
                 'ending'      => '04/21/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Beer/Wine Focus'
+                'category'    => 3
             ),
             array(
+                'id'          => 8,
                 'title'       => 'Patrick Henry Beer Collectibles Show',
                 'starting'    => '05/14/2016',
                 'ending'      => '05/14/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Beer/Wine Focus'
+                'category'    => 3
             ),
             array(
+                'id'          => 9,
                 'title'       => '"Tasting on the Town"',
                 'starting'    => '05/20/2016',
                 'ending'      => '05/20/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Beer/Wine Focus'
+                'category'    => 3
             ),
             array(
+                'id'          => 10,
                 'title'       => 'Owl Prowl: Barred Owls',
                 'starting'    => '02/25/2016',
                 'ending'      => '02/25/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Outdoor/Nature'
+                'category'    => 7
             ),
             array(
+                'id'          => 11,
                 'title'       => 'Owls of Michigan',
                 'starting'    => '02/28/2016',
                 'ending'      => '02/28/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Outdoor/Nature'
+                'category'    => 7
             ),
             array(
+                'id'          => 12,
                 'title'       => 'Bird Sanctuary Resource Center Re-Opening',
                 'starting'    => '02/29/2016',
                 'ending'      => '02/29/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Outdoor/Nature'
+                'category'    => 7
             ),
             array(
+                'id'          => 13,
                 'title'       => 'Lead Day Hike',
                 'starting'    => '02/29/2016',
                 'ending'      => '02/29/2016',
                 'description' => '<p>Test event description text here!</p>',
-                'category'    => 'Outdoor/Nature'
+                'category'    => 7
             ),
             array(
+                'id'          => 14,
                 'title'       => 'Project Snowstorm: Snowy Owls in Michigan',
                 'starting'    => '03/01/2016',
                 'ending'      => '03/01/2016',
                 'description' => '<p>Test event description text here!</p>',
-                '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' => '<p>Test event description text here!</p>',
-            '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(
index 0dcead7..4fdb966 100644 (file)
@@ -1,41 +1,23 @@
-<h1>Dashboard</h1>
+<h2>Dashboard</h2>
 <div class="row">
-    <div class="small-12 medium-5 columns">
         {include file='front/events/searchForm.html'}
-    </div>
-    <div id="shortcuts" class="small-12 medium-4 columns">
         {include file='front/events/shortCuts.html'}
-    </div>
 </div>
 <div class="row">
-    <div class="small-12 medium-6 columns">
-        <ul class="category-block pricing-table">
-            <li class="title">Arts & Crafts</li>
-            <li class="description text-left">Event title and date</li>
-        </ul>
-    </div>
-    <div class="small-12 medium-6 columns">
-        <ul class="category-block pricing-table">
-            <li class="title">Arts/Cultural Events</li>
-            <li class="description text-left">Event title and date</li>
-        </ul>
-    </div>
-    <div class="small-12 medium-6 columns">
-        <ul class="category-block pricing-table">
-            <li class="title">Beer/Wine Focus</li>
-            <li class="description text-left">Event title and date</li>
-        </ul>
-    </div>
-    <div class="small-12 medium-6 columns">
-        <ul class="category-block pricing-table">
-            <li class="title">Concert/Live Music</li>
-            <li class="description text-left">Event title and date</li>
-        </ul>
-    </div>
-    <div class="small-12 medium-6 columns end">
+    {foreach $catEvents as $catid => $category}
+    <div class="small-12 medium-6 columns{if $category@last} end{/if}">
         <ul class="category-block pricing-table">
-            <li class="title">Educational</li>
-            <li class="description text-left">Event title and date</li>
+            <li class="title">{$categories.{$catid}.name}</li>
+            {foreach $category as $event}
+                {if $event@iteration == 4}
+                    {break}
+                {/if}
+            <li class="description text-left">{$event.title}</li>
+            {/foreach}
         </ul>
     </div>
+    {if $category@iteration is div by 2}
+        </div><div class="row">
+    {/if}
+    {/foreach}
 </div>
index 2e6a83f..d046609 100644 (file)
@@ -1,11 +1,7 @@
 <h1>Event List</h1>
 <div class="row">
-    <div class="small-12 medium-5 columns">
         {include file='front/events/searchForm.html'}
-    </div>
-    <div id="shortcuts" class="small-12 medium-4 columns">
         {include file='front/events/shortCuts.html'}
-    </div>
 </div>
 <div class="row">
     {foreach $events as $event}
@@ -13,8 +9,8 @@
         <div class="row">
             <div class="small-6 medium-2 columns">{$event.starting}</div>
             <div class="small-6 medium-10 columns">
-                {$event.category}<br>
-                <a href="#">{$event.title}</a>
+                {$categories[$event.category].name}<br>
+                <a href="{$thisURL}?eventId={$event.id}">{$event.title}</a>
             </div>
         </div>
         <hr>
index 09526b0..0fbaab3 100644 (file)
@@ -1,43 +1,48 @@
+    <div class="small-12 medium-6 columns">
         <h3 class="text-center">Find An Event</h3>
         <form action="">
             <input type="hidden" name="search" value="1">
             <div class="row">
-                <div class="small-12 medium-6 columns">
+                <div class="small-12 medium-6 text-right columns">
                     <label for="glm-event-name">Event Name </label>
                 </div>
                 <div class="small-12 medium-6 columns">
                     <input id="glm-event-name" name="event_name">
                 </div>
                 <div class="small-12 small-text-center columns">
-                    <input type="submit" class="button">
+                    <input type="submit" class="button radius">
                 </div>
             </div>
         </form>
         <form action="">
             <input type="hidden" name="search" value="1">
             <div class="row">
-                <div class="small-12 medium-6 columns">
+                <div class="small-12 medium-6 text-right columns">
                     <label for="glm-event-from">From</label>
                 </div>
                 <div class="small-12 medium-6 columns">
                     <input id="glm-event-from" name="event_name">
                 </div>
-                <div class="small-12 medium-6 columns">
+                <div class="small-12 medium-6 text-right columns">
                     <label for="glm-event-to">To</label>
                 </div>
                 <div class="small-12 medium-6 columns">
                     <input id="glm-event-to" name="event_name">
                 </div>
-                <div class="small-12 medium-6 columns">
+                <div class="small-12 medium-6 text-right columns">
                     <label for="glm-event-category">Category</label>
                 </div>
                 <div class="small-12 medium-6 columns">
                     <select id="glm-event-category" name="category">
-                        <option></option>
+                        <option value="">-- Select --</option>
+                        {foreach $categories as $cat}
+                        <option value="{$cat.id}"{if $categoryId == $cat.id} selected{/if}>{$cat.name}</option>
+                        {/foreach}
                     </select>
                 </div>
                 <div class="small-12 small-text-center columns">
-                    <input type="submit" class="button">
+                    <input type="submit" class="button radius">
                 </div>
             </div>
         </form>
+    </div>
index 08d4ab9..1304f19 100644 (file)
@@ -1,7 +1,9 @@
+    <div id="shortcuts" class="small-12 medium-4 columns">
         <h3 class="text-center">Shortcuts</h3>
-        <ul class="stack button-group">
+        <ul class="stack button-group radius">
             <li><a href="#" class="button">Today's Events</a></li>
             <li><a href="#" class="button">Tomorrow's Events</a></li>
             <li><a href="#" class="button">Next 7 Days</a></li>
         </ul>
+    </div>