Forum

Thread tagged as: Problem, Runway

Pagination page links template not showing on search results

Hi

I'm trying to create a pagination on the bottom of the search results pages like so...

Pagination

...but nothing is displaying.

Search page code /perch/templates/pages/search.php

    $query = perch_get('q');
    perch_content_search($query, [
        'count' => 10,
        'hide-default-doc' => 'true',
        'template' => 'search-result.html',
        'paginate' => 'true',
        'page-links' => 'true',
      ]);

Search results template /perch/templates/search/search-result.html

 <perch:if exists="paging">
            <perch:content id="page_links" encode="false" />
        </perch:if>

Pagination template `/perch/templates/paination/page-links.html

<perch:before>
    <nav aria-label="Page navigation example">
        <ul class="pagination justify-content-center pagination-lg">
            <li class="page-item<perch:if id="not_first_page"> disabled</perch:if>"><a class="page-link" href="<perch:search id="prev_url" encode="false" />" tabindex="-1"><i class="fal fa-arrow-left"></i></a></li>
</perch:before>

            <li<perch:if exists="selected"> class="active"</perch:if>><a href="<perch:pages id="url" />"><perch:pages id="page_number" /></a></li>

<perch:after>
            <li class="page-item<perch:if id="not_last_page"> disabled</perch:if>"><a class="page-link" href="<perch:search id="next_url" encode="false" />"><i class="fal fa-arrow-right"></i></a></li>
        </ul>
    </nav>
</perch:after>

Debug isn't showing any errors.

Many thanks

Glen Piggott

Glen Piggott 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What does <perch:showall /> output? Do you see the pagination variables?

Hi Drew.

It looks like they're there...

ID  Value
perch_page_path /search
domain  https://wga.dns-systems.net
url /business/employment-law
sitename    Ward Gethin Archer
sharing_image   /perch/resources/social-media/default.jpg
twittername @WGAsolicitors
title   Employment Law
excerpt Commercial Employment Law
pageTitle   Employment Law
pageNavText Employment Law
source  PerchContent
region_key  Hero
result_url  /business/employment-law
result_title    Employment Law
result_excerpt  Commercial Employment Law
result_pageTitle    Employment Law
result_pageNavText  Employment Law
result_source   PerchContent
result_region_key   Hero
search_key  employment
key employment
_id 173
heroImg 
text    Commercial Employment Law
intro   
result_result_url   /business/employment-law
result_result_title Employment Law
result_result_excerpt   Commercial Employment Law
result_result_pageTitle Employment Law
result_result_pageNavText   Employment Law
result_result_source    PerchContent_SearchHandler
result_result_region_key    Hero
result_search_key   employment
result_key  employment
result__id  173
result_heroImg  
result_text Commercial Employment Law
result_intro    
paging  true
total   75
number_of_pages 8
total_pages 8
per_page    10
current_page    1
lower_bound 1
upper_bound 10
prev_url    
next_url    /search?q=employment&page=2
prev_page_number    
next_page_number    2
first_page_url  /search?q=employment
last_page_url   /search?q=employment
first_page  true
not_last_page   true
page_links  1 2 3 … 8 {...}
perch_item_last true
perch_item_zero_index   9
perch_item_index    10
perch_item_rev_index    1
perch_item_rev_zero_index   0
perch_item_odd  odd
perch_item_count    10
perch_index_in_set  10
perch_zero_index_in_set 9
perch_namespace perch:search
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you look at the last line:

perch_namespace perch:search

That tells you that you should be using <perch:search /> tags in this context, and it looks like you're using <perch:content />