Forums Forums Search & Filter Pro Results don't show with AJAX, but do without AJAX

Viewing 10 posts - 21 through 30 (of 31 total)
  • Anonymous
    #73844

    Ok. I’ve made the adjustment to the /sort-filter page

    Anonymous
    #73846
    This reply has been marked as private.
    Trevor
    #73941

    Something in the theme is interfering with the S&F plugin arguments. I think it will be necessary to switch to the Shortcode Display method. The results will not look as nice, but that can be fixed as long as you follow the customizing guide in the documentation.

    Anonymous
    #74227

    Ok. I really don’t know what could be causing the issue since this is a bare bones theme. I don’t think I can get it customized the way we need it by going the shortcode route. I hate to ask but would it be possible to get a refund on it?

    Your support has been top notch. I really wish we could have gotten it resolved!

    Trevor
    #74516
    This reply has been marked as private.
    Anonymous
    #74935
    This reply has been marked as private.
    Ross Moderator
    #75054

    Hi there!

    Trevor asked me to look at this ticket, and I think I can see what is going wrong…!

    So, lets start with the basic example you provided and work from there:

    http://oaj.flywheelsites.com/sort-filter/

    In S&F, you have various display methods (ways in which your results are displayed):

    https://www.designsandcode.com/documentation/search-filter-pro/search-results/#Display_Results_Method

    If you take a look at the options there, you will realise none of these apply to what you are trying to do.

    In fact, what you are trying to do, is integrate S&F with another plugin, which uses a shortcode to display your posts… So the only option left for us (and I just realised its not in teh docs) is to use the “custom” display method.

    What we need to do next, is find a way to let S&F know that it needs to affect this display-results shortcode.

    Luckily, S&F provides a simple way to do this, if we can access the query that is used to generate your posts then we can attach S&F to it.

    For any WP query, if you add the argument search_filter_id and put the ID of your search form, then S&F will affect that loop/query.

    Taking a look at the display posts plugin, they do indeed have a method which allows you to edit the query / arguments!

    http://www.billerickson.net/code/display-posts-shortcode-exclude-posts/

    So what you will need to do (untested/pseudocode, I’ve never used this plugin before) is add a S&F argument as per the instructions at the above link:

    function be_display_posts_shortcode_exclude_posts( $args, $atts ) {
    	if( isset( $atts['search_filter_id'] ) ) {
    		$search_filter_id = $atts['search_filter_id'];
    		$args['search_filter_id'] = $search_filter_id ;
    	}
    		
    	return $args;
    }
    add_filter( 'display_posts_shortcode_args', 'be_display_posts_shortcode_exclude_posts', 10, 2 );
    

    So from my limited understanding of that plugin, this should allow you to add a search_filter_id argument to your shortcode.. so with the code above, your shortcode should look like (notice the last argument):

    [display-posts include_excerpt="true" posts_per_page="10" wrapper="div" excerpt_more="..." wrapper_id="dynamic-articles" search_filter_id="8277"]

    So, with the code above, the new argument on the shortcode, all you will need to do is update the display results method to custom (under the display results tab in S&F), and then also update the results url (this option is revealed when choosing “custom”) to http://oaj.flywheelsites.com/sort-filter/

    I didn’t try / make any of these changes because I don’t want to break the site with some PHP error, and also not familiar with that plugin… but I’m pretty confident this is the correct approach to get S&F to work with your posts plugin!

    Does all that make sense?

    Best

    Anonymous
    #75116

    Ross – Thank you so much for your detailed response! I can definitely see the advantage of your solution. Before implementing it though, I can say that what we’re trying to accomplish is to have the five columns of categories (the #dynamic-articles div) fade out and then be replaced by the simple, single column archive of the post results (as is displayed on the results page when AJAX is turned off).

    From your suggestion, I’m guessing that what might happen is that all seven areas where I’ve implemented the display-posts shortcode on the homepage will then return the filtered results.

    I will confirm once I’ve implemented the code.

    Thank you again for your very detailed and thoughtful response!

    Anonymous
    #75119

    Ross – Well, it looks like we are halfway there! I added the function to my child theme’s functions.php file, then initially tried adding the extra display posts shortcode above the existing five column articles area on the homepage. It displays them in a single column (above the five column articles area), but searching / sorting / filtering didn’t work.

    So I tried removing the extra display-posts shortcode on the homepage above the five column area and just leaving the dynamic-articles div intact. The searching / sorting / filtering didn’t work, but at least now the dynamic-articles div does fade out and produce a single archive of posts (in descending order), which wasn’t happening before! I’ve left it like this for now for you to see.

    Ross Moderator
    #75177

    Hi again…

    Ok so I just did a quick test…

    So, I added search_filter_id to your shortcode on this page: http://oaj.flywheelsites.com/sort-filter/ – it seems you didn’t do it, or removed it? Anyway, when I add it the filtering is working perfectly (with ajax)!

    Great news… I think what you didn’t realise is now on yoru display posts shortcode you have a new attribute:

    [display-posts search_filter_id="xxx"]

    This means that only the shortcodes that have the search_filter_id will be affected by S&F! So all your other display-posts shortcodes will not be affected at all.

    Now… what you specifically want to do is not a S&F feature and is not possible with S&F alone (what you are asking is really out of the support realm of S&F).

    You want to do a search, and it replace your grid, with the search results (in the single column format)?

    So, what I have done is create a new search form (duplicate from your previous)… update the results URL to your homepage, and of course update all references to the old ID to the new search form ID – 8378

    Then I added the same display-results shortcode we had on the sort-filter page to your homepage, and added the new search_filter_id="8378"

    As you can see it is now working perfectly! (albeit some layout issues)…

    So my suggestion to you would be, using CSS is to hide the new container for search results which I gave the ID of #search-filter-results-container.. so when the page loads it looks normal and the search results are hidden…

    Then, when the search form is submitted, and ajax is complete (I can see earlier in the thread you know how to detect sf:ajaxfinish, to hide/fadeout all your columns with Javascript, and to fadein this div #search-filter-results-container!

    It seems to me the only task left is to show/hide the correct containers when a search is submitted, it just seems there is some layout work to do so it looks smooth from your side 🙂

    I’m online now for about an hr, but after that I will be unavailable and I’m away tomorrow so won’t get back to you until monday.

    However, considering what is left, I’m sure you can figure it out, if not Trevor will be able to help point you in the right direction, but as mentioned, now what is left is really a little out of S&F support and I guess would fall under theme development, but of course we will try to help out where we can!

    Best 🙂

Viewing 10 posts - 21 through 30 (of 31 total)