• Resolved lackadaize

    (@lackadaize)


    Hi. I’ve been asked to template the events list page so that both the main search and the advanced search are hidden by default but have buttons so that each will be shown in much the way that the advanced search button shows it’s hidden div. Each button would show their respective searches as opposed to the advanced search button being contained within the main search. As far as I can tell this is controlled with a rel attribute as seen in the following code in events-search.php:

    <div class="em-search-options">
    			<a href="#" rel=".em-search-advanced:.em-search-form">
    				<span class="hide" style="display:none;"><?php echo esc_html($args['search_text_hide']); ?></span>
    				<span class="show"><?php echo esc_html($args['search_text_show']); ?></span>
    			</a>
    		</div>

    What I believe I need to do is create a rel attribute similar to that referenced by rel=".em-search-advanced:.em-search-form" but I can’t seem to find where to create the attribute. Do you have any tips on how/where to do this? I believe if you can just tell me how the rel attribute is established I should be able to figure the rest of the templating out. Thank you very much for you time.

    https://www.ads-software.com/plugins/events-manager/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    hi,

    you can try to modify template file under events-manager/templates/templates/events-search.php

    to use templates: https://wp-events-plugin.com/documentation/using-template-files/

    Thread Starter lackadaize

    (@lackadaize)

    I’ve modified it quite a bit to the code you see below and it’s working to my liking. The only thing that’s not working correctly is the advanced search doesn’t actually sort the list and I can’t figure out why, but the main search works just fine. Not sure what I’m missing? The page is at https://new.pharmavoice.com/?page_id=132901 for reference.

    $args = !empty($args) ? $args:array(); /* @var $args array */
    ?>
    <div class="em-search-wrapper">
    <div class="em-events-search em-search <?php if( !empty($args['main_classes']) ) echo esc_attr(implode(' ', $args['main_classes'])); ?>">
    
    	<form action="<?php echo !empty($args['search_url']) ? esc_url($args['search_url']) : EM_URI; ?>" method="post" class="em-events-search-form em-search-form">
    		<div id="events-top-buttons-wrapper">
    			<div id="event-top-buttons">
    				<a href="#" class="em-toggle" rel=".em-search-main:.em-search-form">
    					<span class="hide" style="display:none;"><?php echo 'Hide Event Search'; ?></span>
    					<span class="show"><?php echo 'Event Search'; ?></span>
    				</a>
    				<a href="#" class="em-toggle" rel=".em-search-advanced:.em-search-form">
    					<span class="hide" style="display:none;"><?php echo 'Hide Sort'; ?></span>
    					<span class="show"><?php echo 'Sort'; ?></span>
    				</a>
    				<a href="#">Add Event</a>
    				</div>
    		</div>
    	<input type="hidden" name="action" value="<?php echo esc_attr($args['search_action']); ?>" />
    		<?php if( $args['show_main'] ): //show the 'main' search form ?>
    		<div class="em-search-main" <?php if( !empty($args['advanced_hidden']) ) echo 'style="display:none"'; ?>>
    			<?php do_action('em_template_events_search_form_header'); //hook in here to add extra fields, text etc. ?>
    			<?php
    			//search text
    			if( !empty($args['search_term']) ) em_locate_template('templates/search/search.php',true,array('args'=>$args));
    			if( !empty($args['search_geo']) ) em_locate_template('templates/search/geo.php',true,array('args'=>$args));
    			?>
    			<?php if( !empty($args['css']) ) : //show the button here if we're using the default styling, if you still want to use this and use custom CSS, then you have to override our rules ?>
    			<button type="submit" class="em-search-submit loading">
    				<?php //before you ask, this hack is necessary thanks to stupid IE7 ?>
    				<!--[if IE 7]><span><![endif]-->
    				<img src="<?php echo EM_DIR_URI; ?>includes/images/search-mag.png" />
    				<!--[if IE 7]></span><![endif]-->
    			</button>
    			<?php endif; ?>
    		</div>
    		<?php endif; ?>
    		<?php if( !empty($args['show_advanced']) ): //show advanced fields, collapesed if the main form is shown, inline if not ?>
    		<div class="em-search-advanced" <?php if( !empty($args['advanced_hidden']) ) echo 'style="display:none"'; ?>>
    			<?php
    			//date range (scope)
    			if( !empty($args['search_scope']) ) em_locate_template('templates/search/scope.php',true,array('args'=>$args));
    			//categories
    			if( !empty($args['search_categories']) ) em_locate_template('templates/search/categories.php',true,array('args'=>$args));
    			//Location data
    			em_locate_template('templates/search/location.php',true, array('args'=>$args));
    			if( !empty($args['search_geo_units']) ) em_locate_template('templates/search/geo-units.php',true, array('args'=>$args));
    			?>
    			<?php do_action('em_template_events_search_form_footer'); //hook in here to add extra fields, text etc. ?>
    			<?php if( !$args['show_main'] || empty($args['css']) ): //show button if it wasn't shown further up ?>
    			<input type="submit" value="<?php echo esc_attr($args['search_button']); ?>" class="em-search-submit" />
    			<?php endif; ?>
    		</div>
    		<?php endif; ?>
    		<?php if( !empty($args['advanced_hidden']) && !empty($args['show_advanced']) ): //show the advanced search toggle if advanced fields are collapsed ?>
    		<?php endif; ?>
    		<?php if( (empty($args['show_advanced']) || empty($args['search_countries'])) && !empty($args['country']) ): //show country in hidden field for geo searching ?>
    		<input type="hidden" name="country" value="<?php echo esc_attr($args['country']) ?>" />
    		<?php endif; ?>
    	</form>
    
    </div>
    <?php if( !empty($args['ajax']) ): ?><div class='em-search-ajax'></div><?php endif; ?>
    </div>

    Thanks again for your help.

    Thread Starter lackadaize

    (@lackadaize)

    OK, now I understand that the form submit button needs to be pressed for the advanced search as well.

    I tried deleting
    <?php if( !$args['show_main'] || empty($args['css']) ): //show button if it wasn't shown further up ?>
    But then it broke the whole page because there would be two submit buttons for the same form. Do you think there would be any issues if I made them two completely seperate forms or would you see this as an issue? THanks again for your help.

    Thread Starter lackadaize

    (@lackadaize)

    I was able to make this work with two separate forms, but stylistically I may need to break it down into a ul li setup.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Give "em-search-main" rel attribute similar to "em-search-advanced"’ is closed to new replies.