All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Low search pagination

cweinard 3 Nov 2013 21:33 problem, complete

Hello--I'm new to Low Search. Pagination seems to work fine on the first page of results, but on subsequent pages it breaks. (The search query doesn't appear in the url.) How do I fix? Thanks--

Low Search 2.4.2 / EE2.5

Example:
http://ncartmuseum.org/art/search?col...

 
{exp:low_search:form collection="works_of_art" search_mode="all" result_page="art/search"}
<fieldset>
<label for="keywords">Keywords</label>
<input type="search" name="keywords" id="keywords" />
<button type="submit">Search</button>
</fieldset>
{/exp:low_search:form}

{exp:low_search:results query="{segment_3}" limit="20" collection="works_of_art" paginate="bottom"}
{if count == 1}<ul>{/if}
<li><a href="/art/{url_title}">{title} by {cf_works-of-art_maker}</a> </li>
{if count == total_results}</ul>{/if}
{if no_results}No search results{/if}
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{/exp:low_search:results}

Replies

  1. Low 3 Nov 2013 22:25

    Can you try either putting the Encode Query setting to Yes, or remove the query="{segment_3}" parameter from the Results tag if the Encode Query setting is set to No?

  2. cweinard 4 Nov 2013 01:53

    Looks like setting Encode Query to Yes works.
    Removing the query="{segment_3}" parameter when the Encode Query setting is No does not work.

    How can I get it to work without the encoded query? The clean urls are important for this application.

    Thanks!

  3. Low 4 Nov 2013 07:23

    Can you try and set the "URL to the root directory of your site" setting over at CP Home > Admin > General Configuration to the full URL of the site, so starting with http:// instead of a relative path?

  4. cweinard 5 Nov 2013 02:22

    Hmmm. I was a bit hesitant with that one--I tried adding

    $config['site_url'] = "http://www.website.org/"

    to config.php instead of going through the CP.

    The homepage came up blank, so I removed it. Any other suggestions?

  5. cweinard 5 Nov 2013 04:02

    Correction--I tried again...

    I added...

    $config['site_url'] = "http://website.org/";

    to config.php and the site works (I see the change reflected in General Configuration) but there's no change to the pagination behavior.

    It's still not giving proper urls in the pagination links.

  6. Low 5 Nov 2013 07:57

    Then try and use the {pagination_links} as a variable pair (see http://ellislab.com/expressionengine/...) and use this in your hrefs: {pagination_url}{low_search_query_string}

  7. cweinard 5 Nov 2013 15:27

    Added the {pagination_links} code--still no luck. It looks like it adds to the query string until it becomes too large.

    Thanks so much for your help, by the way.

     
    {exp:low_search:form collection="works_of_art" search_mode="all" result_page="art/search"}
    <fieldset>
    <label for="keywords">Keywords</label>
    <input type="search" name="keywords" id="keywords" />
    <button type="submit">Search</button>
    </fieldset>
    {/exp:low_search:form}

    {exp:low_search:results {!--query="{segment_3}"--} limit="20" collection="works_of_art" paginate="bottom" }
    {if count == 1}<ul>{/if}
    <li><a href="/art/{url_title}">{title} by {cf_works-of-art_maker}</a> </li>
    {if count == total_results}</ul>{/if}
    {if no_results}No search results{/if}
    {!--
    {paginate}
    <p>Page {current_page} of {total_pages} pages {pagination_links}</p>
    {/paginate}
    --}
    {paginate}
    {pagination_links}

    <ul>
    {first_page}
    <li><a href="{pagination_url}{low_search_query_string}" class="page-first">First Page</a></li>
    {/first_page}

    {previous_page}
    <li><a href="{pagination_url}{low_search_query_string}" class="page-previous">Previous Page</a></li>
    {/previous_page}

    {page}
    <li><a href="{pagination_url}{low_search_query_string}" class="page-{pagination_page_number} {if current_page}active{/if}">{pagination_page_number}</a></li>
    {/page}

    {next_page}
    <li><a href="{pagination_url}{low_search_query_string}" class="page-next">Next Page</a></li>
    {/next_page}

    {last_page}
    <li><a href="{pagination_url}{low_search_query_string}" class="page-last">Last Page</a></li>
    {/last_page}
    </ul>
    {/pagination_links}
    {/paginate}

    {/exp:low_search:results}

  8. Low 5 Nov 2013 15:33

    Actually, it looks like it's being added twice, now. Very strange; I tried to replicate this behaviour several times, but never got this. I'll need to take a look myself. Please send SuperAdmin login credentials to hi at gotolow dot com if you can.

  9. Low 6 Nov 2013 07:53

    For visibility: I was able to fix the issue by making a small change to the mod.low_search.php file. However, the cause may be linked to either a bug in EE or Structure, so I'd recommend upgrading where possible.