Hey TJ
I think its a matter of ordering of events – S&F probably does scroll but the masonry call is messing this up somehow (perhaps the masonry script uses scrollTop somewhere and this clashes with S&F).
I would try to manually add the scrolling back in after the masonry call – so taking some scrolling code from S&F (with modification):
var scrollToPos = function()
{
var offset = 0;
var canScroll = true;
if(jQuery("#focus-results").length>0)
{
offset = jQuery("#focus-results").offset().top;
}
$("html, body").animate({
scrollTop: offset
}, "normal", "easeOutQuad" );
};
Then after masonry you could do scrollToPos();
You might even need to add a delay for masonry to complete so:
setTimeout(function(){ scrollToPos(); }, 100);
Just to confirm, if you do not use that masonry script scrolling works fine?
Let me know how you get on.
Thanks
AnonymousInactive
Hello,
Quick one, I’m using masonry on my Ajax results so I call it back in as below :
<script type="text/javascript">
( function($) {
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
$('.grid-archive').masonry();
});
} ) ( jQuery );
</script>
But since doing that it no longer scrolls to my results container, I’ve tried a scroll to myself within the above js but it doesn’t work as well as yours. Anything I can do?
Thanks 🙂
AnonymousInactive
The file template is “archive.php”
and this is the code on it:
<?php
/**
* Archive pages.
*
* @package vogue
* @since 1.0.0
*/
// File Security Check
if ( ! defined( ‘ABSPATH’ ) ) { exit; }
$config = presscore_get_config();
$config->set( ‘template’, ‘archive’ );
$config->set( ‘layout’, ‘masonry’ );
$config->set( ‘template.layout.type’, ‘masonry’ );
get_header(); ?>
<!– Content –>
<div id=”content” class=”content” role=”main”>
<?php
if ( have_posts() ) :
do_action( ‘presscore_before_loop’ );
// backup config
$config_backup = $config->get();
// masonry container open
echo ‘<div ‘ . presscore_masonry_container_class( array( ‘wf-container’ ) ) . presscore_masonry_container_data_atts() . ‘>’;
while ( have_posts() ) : the_post();
presscore_archive_post_content();
$config->reset( $config_backup );
endwhile;
// masonry container close
echo ‘</div>’;
dt_paginator();
do_action( ‘presscore_after_loop’ );
else :
get_template_part( ‘no-results’, ‘search’ );
endif;
?>
</div><!– #content –>
<?php do_action(‘presscore_after_content’); ?>
<?php get_footer(); ?>
AnonymousInactive
Hi, my site has a masonry layout which I’d like to make compatible with the ajax feature. Are there any callback functions where I could fire the masonry engine so it updates the layout after loading results? Thanks.
Hi Stephanie
The reason you are having layout / masonry issues is because you are using ajax.
If you disable ajax, I’m assuming the rest works well?
When using JS to control layouts with Ajax, the issue is that all the scripts that would normally get triggered on a regular page load don’t occur when an ajax request is performed.
If you take a look at this JS event (first question):
http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/
You’ll notice there is an event for detecting when ajax content has loaded.
You must use this event to reload any scripts like your masonry script.
Thanks
AnonymousInactive
Likewise the masonry script doesn’t load.
I’m not sure how to fix this with the provided instructions.
Hi Stephanie
Ok I see what is going on.
When you load the page, Avada runs some JS, that basically lays out the page in this Masonry style.
So, when you don’t have Ajax, a page loads, runs Avada layout JS – however, with ajax, Avada JS is not run every time – because you are not reloading the page.
Please see the first question in the FAQs – http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/ – there are events to use which tell you when S&F has loaded the results via JS, and it is here you would add the Avada layout code.
If you want to modify the page title, it is possible but not a feature of S&F directly just yet.
Please see this post with some more information: https://support.searchandfilter.com/forums/topic/custom-page-titles-meta-descriptions/
What you want to do is use the WP filter for page titles, and modify it using the the Active Query class found here: http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/
Thanks
Scratch that, I just removed the text “Search Results for:” (and its container) via firebug, resized the page and masonry seemed to work perfect 🙂
Thanks
Hey Marsha
Really you should always specify a custom template – otherwise you will not be able to specifically control what template is being used.
That being said, it sounds like the template that is being used has a better layout for the masonry code, than the one being used when you specify it by file name.
What I would think to do is
1) Identify the template file being loaded, when you don’t tick “use custom template”
2) Identify the differences between this template, and the template being used when you do tick “use custom template”
I think this is the best approach to figure out where something is going wrong.
The only other thing I would say is, the page title on your search results, seems to be inside the masonry container, so maybe that is throwing things off? Maybe just remove the text “Search Results for:”
Thanks
AnonymousInactive
I am trying to get my search results to display properly with my masonry theme. I attempt to fix it on my own. I unchecked “Use a custom template for results?” but only my taxonomies displayed any results after that – anything under categories came back with “No results found”. So I put the check mark back, but now the formatting is still wonky. http://couponingincanada.ca/