Search Form
WordPress Event Management, Calendars & Registration › Forums › General Question › Search Form
This topic contains 7 replies, has 2 voices, and was last updated by Irene Bautista 11 years, 5 months ago.
-
AuthorPosts
-
July 18, 2013 at 2:48 am #6537
I am trying to display events in a single category on a page. I didn’t want to use the default category url (events/category/…) because I have preceding content that needs to show before the event list.
So, I was able to add the shortcode to show the events list on a page I created with the search shortcode placed above it. My problem is that the search form shortcode also shows a list of ALL my events underneath it. How can I show the search form without showing the events list with it until someone searches.
Thanks!
Irene BautistaJuly 18, 2013 at 2:26 pm #6542Hi Irene,
You can achieve this my copying the
search-event-list.php
template (inevent-organiser-pro/templates
) to your theme and editing it to display the results only when the user as entered a search term.Opening up that template, near the top you’ll see
<?php if ( $eo_event_loop->have_posts() ): ?>
This is checks if there are events to show before trying to display them. You can add an extra condition in there to the effect “if the user has entered a search term AND there are events to show… then show events”: i.e. replace that line with:
<?php if ( !empty( $_REQUEST['eo_search'] ) && $eo_event_loop->have_posts() ): ?>
And that should do it.
You’ll probably find that the pagination is still showing (I’ll be fixing this in the next update, but since you’re customising the template you’ll need to change this in your copy).
The pagination bit is (at the bottom):
<?php if ( $eo_event_loop->max_num_pages > 1 ) : //See http://codex.wordpress.org/Function_Reference/paginate_links $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var( 'paged' ) ), 'total' => $eo_event_loop->max_num_pages ) ); endif; ?>
And you can either move that entire block of code so that it sites above the
<?php endwhile; ?>
or your change that first line to:<?php if ( !empty( $_REQUEST['eo_search'] ) && $eo_event_loop->max_num_pages > 1 ) :
Similar to above.
I hope that helps, if you have any problems with the above just let me know!
Stephen HarrisJuly 18, 2013 at 6:45 pm #6545Hi Stephen,
Thanks for the quick reply! Works perfectly! Thank you so much! I knew it’d be something really simple! Have a great day!
-Irene
Irene BautistaAugust 28, 2013 at 7:30 pm #7071Hi Stephen, I am using the following shortcode
[event_search filters="event_category,city,state,date,country"]
to include a search form on several event pages. I just noticed that the state select field isn’t holding the selected option when searching. Any ideas why it would be doing this all of a sudden? FYI – quite a few new events have been added in the last few days and some were entered incorrectly and had to be fixed – not sure if this has anything to do with it though.Thanks!
Irene
Irene BautistaAugust 28, 2013 at 8:13 pm #7072Hi Irene,
Yup, there’s a bug with this. I’ll be including the fix in 1.4 update (beta due out soon). In case its urgent I’ve included the changes below – if you have any difficulty with making the changes, feel free to get in touch via this form and I’ll email you the updated file.
In
includes/shortcodes.php
lines 210-224 (the country filter section) change ‘1’ to ‘2’ (on lines 216, 221 and 224), so it should be:$html .= sprintf( '<li class="%1$s"><label for="%2$s">%3$s</label><p>%4$s</p></li>', 'country event-country', 'event-country', __( 'Country', 'eventorganiser' ), eventorganiser_select_field( array( 'name' => 'eo_search[venue_query][2][value]', 'id' => 'event-venue', 'echo' => false, 'options' => $countries, 'show_option_all' => __( 'All countries', 'eventorganiserp' ), 'selected' => isset( $input['venue_query']['2']['value'] ) ? $input['venue_query']['2']['value'] : '', ) ) ); $html .= '<input type="hidden" name="eo_search[venue_query][2][key]" value="_country">';
Stephen HarrisAugust 29, 2013 at 2:19 am #7082Hi Stephen, this worked for a second and now stopped working… One last thing on the search form – How can I get the cities and states to sort alphabetically in the state and city select fields? -Irene
- This reply was modified 11 years, 5 months ago by Irene Bautista.
Irene BautistaAugust 29, 2013 at 11:35 am #7087Hi Irene,
That’s odd, in what way stopped working? (If you’d like me to take a look, or make the changes, feel free to use this form to provide admin & ftp details – I would otherwise release a bug-fix update, but 1.4 shall be released as beta later today / tomorrow )
How can I get the cities and states to sort alphabetically in the state and city select fields?
I’ll ensure they are sorted alphabetically in 1.4!
Stephen HarrisAugust 30, 2013 at 12:04 am #7094Hi Stephen,
Yeah – it now holds the state selected but comes up with no results. I’ll send you the details for admin and ftp – thanks! 🙂Irene
Irene Bautista -
AuthorPosts