Forums Forums Search & Filter Pro Initial results page has no results after removing a filter via ajax

Tagged: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #215612

    https://wtg.wpengine.com/the-library/

    Works just fine.

    If you select any filter from the drop down (try content types > blog posts for example). Then remove that filter, it returns to https://wtg.wpengine.com/the-library however there are no results.

    I’ve noticed that this page also yields no results:
    https://wtg.wpengine.com/?sfid=5958&sf_action=get_data&sf_data=all

    Here’s my results page (I’m using some javascript templating and converting the $query results to a JSON array to render the HTML)… so searching for “var libCardJson” in the source code will show you the results (on the page in question libCardJson is ‘[ ]’… i.e. an empty array).

    Additionally using pagination from the initial results page does the same thing (no results).

    Adding multiple filters and removing one at a time does not cause the same issue (only when you clear the last filter and return to the initial results page).

    Any insight or just some more info on how to trouble shoot this would be much appreciated!

    Thanks!

    <?php
    /**
     * Search & Filter Pro 
     *
     * Sample Results Template
     * 
     * @package   Search_Filter
     * @author    Ross Morsali
     * @link      http://www.designsandcode.com/
     * @copyright 2015 Designs & Code
     * 
     * Note: these templates are not full page templates, rather 
     * just an encaspulation of the your results loop which should
     * be inserted in to other pages by using a shortcode - think 
     * of it as a template part
     * 
     * This template is an absolute base example showing you what
     * you can do, for more customisation see the WordPress docs 
     * and using template tags - 
     * 
     * http://codex.wordpress.org/Template_Tags
     *
     */
    
    ?>
    
    <?php
    
    	global $paged;
    	global $wp_query;
    	global $templateid;
    	global $term_name;
    	
    	$blogid = 5961;
    	
    	$templateid = '';
    	
    	if(is_home() && empty($_GET)) {
    		$templateid = $blogid;
    	} elseif(is_tax()) {
    		$templateid = 'term_' . get_queried_object_id();
    	}	
    ?>
    
    <!-- <button data-toggle="modal" data-target="#filters-modal">Filters Modal</button> -->
    <?php include(realpath(dirname(__FILE__)). '/../templates/lib/lib-single-tax.php'); ?>
    
    <?php if( is_library_ajax() ) : ?>
    	
    	<script id="lib-results-meta-data">
    		
    		var totalresults = <?php echo $query->found_posts; ?>;
    				
    	<?php if($query->found_posts >= 1 && $query->query['paged'] > 0) { ?>
    		var pagedtext = "Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br />";
    	<?php } ?>
    	
    	</script>
    	
    <?php endif; ?>
    
    <div id="results-meta-wrap<?php if( is_library_ajax() ) { echo '-ajax'; } ?>"<?php if( is_library_ajax() ) { echo ' class="none"'; } ?>>
    	<?php include(realpath(dirname(__FILE__)) . '/../templates/lib/lib-search.php'); ?>
    
    			<div class="bg-bggray lib-filter--sort-wrap">
    				<div class="container-fluid">
    					
    					<?php if( !is_library_ajax() ) : ?>
    							
    					<div class="group pr lib-filter--sort-container">
    						<div class="fl mbh small-caps lib-filter--total-wrap">
    							<span id="lib-results--total">Found <?php echo $query->found_posts; ?> Results</span>
    							&nbsp; <span class="c-graytext small-caps"<?php if($query->found_posts == 0) { echo ' style="display:none"'; } ?> id="lib-results--paging-title">Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?></span>
    						</div>
    						
    						<div class="fr-1200 lib-filter--options">
    							<div class="tar tal-1200 lib-filter--options-label small-caps">
    								<span class="none inline-block-1200">View Options</span>
    								<span class="none-1200">&nbsp;</span>
    							</div>
    							
    							<div class="inline-block mbh">
    								<button id="grid-view" class="selected icon-grid inline-block" title="Grid View"></button>
    								<button id="list-view" class="icon-list inline-block" title="List View"></button>
    							</div>
    							
    							<select id="lib-filter--sort" title="">			
    								<option>Sort Results By</option>
    							</select>
    				
    							<select id="lib-filter--ppp" title="">
    								<option>Posts Per Page</option>
    							</select>			
    						</div>
    					</div>
    					<?php endif; ?>
    					
    					<div class="lib-results--filters-wrap"<?php if( is_library_ajax() ) { echo ' id="lib-results--ajax-filters"'; } ?>>
    						<?php getFilterLinks(); ?>
    					</div>
    				</div>
    			</div>
    
    </div>
    
    <div class="container-fluid mt6">
    	
    	<div role="main">
    		<section class="" id="filter-results">
    
    			<div class="lib-card--wrap grid-3-2-1 flex-wrap-600 lib-card--grid-view tal">
    			<?php 
    					$resultshtml = array();
    
    					if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post();
    						global $post;
    						//$resultshtml .= get_lib_card($post);
    						$resultshtml[] = get_lib_card_data($post);
    					endwhile; endif;
    					//echo $resultshtml;
    					
    					$thescript = '';
    					
    					$thescript .= '
    						<script>
    							var libCardJson = ' . json_encode($resultshtml, JSON_HEX_QUOT | JSON_HEX_TAG) . ';
    							var theTemplate = "' . get_lib_card_js_template() . '";
    							
    							';
    					
    						if(!is_library_ajax()) {
    							$thescript .= '
    								var defaultJson = libCardJson;
    								var notAjax = true;
    								var $defaultPagination = jQuery(".search-filter-results .pagination").clone();
    							';
    						} else {
    							$thescript .= 'var notAjax = false;';
    						}
    					$thescript .= '
    					
    						</script>
    					';
    				?>
    			</div>
    			
    		</section>
    	</div>
    </div>
    
    <div class="container-fluid">
    	<div class="row">
    		<div class="col-xs-12 tac">
    			<div class="pagination pr tac mt4">
    			<?php
    			    $total_pages = $query->max_num_pages;
    			 	
    			    if ($total_pages > 1){
    			        $current_page = max(1, $query->query['paged']);
    			 		
    
    					$big = 999999999; // need an unlikely integer
    					
    					echo paginate_links( array(
    						'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    						'format' => '?paged=%#%',
    						'current' => $current_page,
    						'prev_text' => __(''),
    						'next_text' => __(''),
    						'before_page_number' => '<div>',
    						'after_page_number' => '</div>',
    						'total' => $query->max_num_pages
    					) );
    			    }
    			?>
    			</div>
    		</div>
    	</div>
    </div>
    
    <?php
    	echo $thescript;
    ?>	
    Trevor
    #215629

    Whilst keeping safe that copy of the results file, what happens if the standard results.php file is used instead?

    My guess is that it will work. If so, who wrote the code in your results.php file?

    Anonymous
    #215638

    I wrote the code…

    Using the default results.php now and still no results.

    https://wtg.wpengine.com/?sfid=5958&sf_action=get_data&sf_data=all

    Trevor
    #215640

    The URL you give there is typical of one used for the ‘As an Archive’ display method, not the shortcode method? You are using the Shortcode results method, yes? So why does the URL look like that with ?sfid in it?

    Anonymous
    #215644

    I copied it from the html form element’s “data-ajax-url” …

    I also added a console.log() statement in the search-filter-pro JS file which logged the ajax URL to confirm.

    Trevor
    #215651
    This reply has been marked as private.
    Anonymous
    #215687

    This was solved with

    define('WPE_GOVERNOR', false);

Viewing 7 posts - 1 through 7 (of 7 total)