I have Derek Hogue's solution to infinite scroll working, with magicspon's fix for the issue of preventDefault being ignored: Infinite scroll and pagination on ee?? Anyone has this working?

This works great until I encapsulate the markup in IF conditionals, whereby the results don't update. I have tried early parsing using IfElse, but this has no effect. Why might this be?

Here's the full working test template:


{if "{segment_2}"==""}

<div id="entry-container" data-behaviour="moreEntries">
     <div class="ajax-wrapper">


    {if no_results}
        <div class="entry">
            <article style="min-height: 600px;">
                    <h1>No Results</h1>
                Check back soon for more blog posts. 
        </div> <!-- /.entry -->
    <div class="entry">
    </div> <!-- /.entry -->

    <p class="moreEntries">
        {if next_page}<a href="{auto_path}" class="more" id="next">See More Posts</a>{/if}

<link href="{site_url}css/styles.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="{site_url}bootstrapvalidator/css/bootstrapValidator.min.css"/>

<script src="{site_url}js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

<script type="text/javascript">
    $('#entry-container').delegate('.more', 'click', function(e)
        // Don't follow the link

        // Create a loading message and add it in place of the link
        loadingMessage = $('<p class="loading">Loading...</p>');

        // Fetch the next page
        $.get($(this).attr('href'), function(data)
            // Only grab the part of the page we want
            content = $(data).find('.ajax-wrapper').hide();

            // Add it to the DOM

            // Remove loading indicator 

            // Fade-in our new content

2 Answers 2


Don't use the curly brackets and quotes on the segment in your conditional. Write your conditional like this:

{if segment_2 == ""}


  • your closing div for entry-container is missing the last character.
  • Your link tags should be in de head of the document
  • The final script tag is not closed.
  • Thank you, but this makes no difference. Commented Jun 4, 2015 at 12:57
  • I updated my answer. Commented Jun 5, 2015 at 15:41
  • Ah, both the missing character and final script tag got lost when I copied the information to StackExchange. They exist in the original template, and I have updated my question. The link tags are in the footer so as not to block page rendering. This is normal practice and helps the Google PageSpeed Insights score. Putting them in the header also makes no difference, though. Commented Jun 5, 2015 at 17:00

Though the URL does not display the pagination segment (e.g. P10), it is valid at the parse stage. I was checking {if "{segment_2}" == ""} and expecting it to be true, but it was actually false because the pagination segment exists when the template parses.

Providing the template conditionals are written with this in mind, infinite scroll works just as well as normal pagination.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.