{"id":94893,"date":"2014-01-20T15:03:37","date_gmt":"2014-01-20T23:03:37","guid":{"rendered":"https:\/\/tri.be\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/"},"modified":"2014-06-07T08:05:15","modified_gmt":"2014-06-07T15:05:15","slug":"custom-search-event-bar-using-custom-views-located-on-every-page","status":"closed","type":"topic","link":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/","title":{"rendered":"Custom Search Event Bar using Custom Views Located on Every Page"},"content":{"rendered":"<p>Hello,<\/p>\n<p>I had an incredibly hard time figuring this out, but I finally managed to get everything working. I thought I would help others using what I learned. Please note that this is not easy to do, but it is possible and does work.<\/p>\n<p>What I needed was a search bar on every page, like the Tribe Bar, that could modify the month\/list\/etc view as neccessary. What I found was that although you can add custom filters and views to the Tribe Bar, I had a very hard time getting to include properly on other pages. In addition, since it is focused on AJAX requests, I couldn&#8217;t get it to POST correctly from a standard WordPress page and filter the results on the subsequent result.<\/p>\n<p>Therefore, I decided to code my own form (very simple form to begin with), that would POST the data to the events page and modify the query as necessary.<\/p>\n<p>What I found was that although, the date query modification was easy (just use \/events\/2013-12 for example and modify the EventDate using the pre_get_posts), this would not filter the events found in each day.<\/p>\n<p>After a lot of searching, I figured out that in the Month view, there is a seperate query using the TribeEventsQuery::getEvents( $args, true ); format in the get_daily_events function in the month template class. This has no filters on it, so therefore there was no way I could figure out how to modify that query (please please add a filter to this, it would have made my life way easier).<\/p>\n<p>In the end, what I found you had to do was create your own view, duplicate the month template class code, change a few things and you would be able to properly do everything you need.<\/p>\n<p>The basic idea is as follows:<\/p>\n<p>1) Create a new view using the Stub Plugin in https:\/\/github.com\/moderntribe\/tribe-events-agenda-view<br \/>\n2) Copy the code from the month.php located underneath the template-classes folder for the plugin.<br \/>\n3) Change classes, make your own, etc.<br \/>\n4) Modify the template files (views) that are included, i.e. content.php, single-day.php, etc to call the static functions from your new class (i.e. My_CustomMonth_Class::is_view_enabled() etc).<br \/>\n5) Change the URL Rewrite for your custom slug:<br \/>\n\t$newRules[trailingslashit( TribeEvents::instance()-&gt;rewriteSlug ) . &#8216;(\\d{4}-\\d{2})$&#8217;] = &#8216;index.php?post_type=tribe_events&amp;eventDisplay=customslug&amp;eventDate=&#8217; . $wp_rewrite-&gt;preg_index(1);<br \/>\n6) DeQueue the various AJAX Calendar scripts (I reused most of the template code)<br \/>\n7) EnQueue your own and modify as necessary so you could still do AJAX calls if you would like (works fine without)<br \/>\n8) In the Events Settings (WP-Admin), change the default view to your new custom one and leave the slug the same (usually \/events\/)<\/p>\n<p>This has given me full flexibility over filtering and finding the events by the following: date, tag, category, location, search (or anything else custom).<\/p>\n<p>The next thing I am doing is adding autocomplete for the category, tag and location fields. I hope this gives some people ideas on how to do this. I simplified a lot of this as it was very complicated to do but a lot of the challanging parts are outlined above. Good luck!<\/p>\n<p>-Adam Listek<\/p>\n","protected":false},"template":"","class_list":["post-94893","topic","type-topic","status-closed","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Custom Search Event Bar using Custom Views Located on Every Page -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Custom Search Event Bar using Custom Views Located on Every Page -\" \/>\n<meta property=\"og:description\" content=\"Hello, I had an incredibly hard time figuring this out, but I finally managed to get everything working. I thought I would help others using what I learned. Please note that this is not easy to do, but it is possible and does work. What I needed was a search bar on every page, like [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/\" \/>\n<meta property=\"article:modified_time\" content=\"2014-06-07T15:05:15+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/\",\"url\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/\",\"name\":\"Custom Search Event Bar using Custom Views Located on Every Page -\",\"isPartOf\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\"},\"datePublished\":\"2014-01-20T23:03:37+00:00\",\"dateModified\":\"2014-06-07T15:05:15+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/theeventscalendar.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\/\/theeventscalendar.com\/support\/topics\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Calendar Products\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Events Calendar PRO\",\"item\":\"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"Custom Search Event Bar using Custom Views Located on Every Page\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/theeventscalendar.com\/support\/#website\",\"url\":\"https:\/\/theeventscalendar.com\/support\/\",\"name\":\"\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Custom Search Event Bar using Custom Views Located on Every Page -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/","og_locale":"en_US","og_type":"article","og_title":"Custom Search Event Bar using Custom Views Located on Every Page -","og_description":"Hello, I had an incredibly hard time figuring this out, but I finally managed to get everything working. I thought I would help others using what I learned. Please note that this is not easy to do, but it is possible and does work. What I needed was a search bar on every page, like [&hellip;]","og_url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/","article_modified_time":"2014-06-07T15:05:15+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/","url":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/","name":"Custom Search Event Bar using Custom Views Located on Every Page -","isPartOf":{"@id":"https:\/\/theeventscalendar.com\/support\/#website"},"datePublished":"2014-01-20T23:03:37+00:00","dateModified":"2014-06-07T15:05:15+00:00","breadcrumb":{"@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/theeventscalendar.com\/support\/forums\/topic\/custom-search-event-bar-using-custom-views-located-on-every-page\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/theeventscalendar.com\/support\/"},{"@type":"ListItem","position":2,"name":"Topics","item":"https:\/\/theeventscalendar.com\/support\/topics\/"},{"@type":"ListItem","position":3,"name":"Calendar Products","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/"},{"@type":"ListItem","position":4,"name":"Events Calendar PRO","item":"https:\/\/theeventscalendar.com\/support\/forums\/forum\/events\/events-calendar-pro\/"},{"@type":"ListItem","position":5,"name":"Custom Search Event Bar using Custom Views Located on Every Page"}]},{"@type":"WebSite","@id":"https:\/\/theeventscalendar.com\/support\/#website","url":"https:\/\/theeventscalendar.com\/support\/","name":"","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/theeventscalendar.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/94893","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/topic\/94893\/revisions"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/support\/wp-json\/wp\/v2\/media?parent=94893"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}