{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2020-05-30T05:47:39Z","object_id":{"id":1296,"is_a":["text","documentation","reference","module"],"name":"doc_module_mod_base","title":"mod_base","uri":"https:\/\/zotonic.com\/id\/1296"},"seq":1000000}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"references":{"objects":[{"created":"2020-05-30T05:47:39Z","object_id":{"id":1843,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_chunk","title":"chunk","uri":"https:\/\/zotonic.com\/id\/1843"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"refers":{"objects":[{"created":"2026-09-09T13:48:08Z","object_id":{"id":1843,"is_a":["text","documentation","reference","template_filter"],"name":"doc_template_filter_filter_chunk","title":"chunk","uri":"https:\/\/zotonic.com\/id\/1843"},"seq":1000000},{"created":"2026-09-09T13:48:08Z","object_id":{"id":1844,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_search","title":"search","uri":"https:\/\/zotonic.com\/id\/1844"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"relation":{"objects":[{"created":"2020-05-30T05:47:39Z","object_id":{"id":1844,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_search","title":"search","uri":"https:\/\/zotonic.com\/id\/1844"},"seq":1000000}],"predicate":{"id":303,"is_a":["meta","predicate"],"name":"relation","title":{"_type":"trans","tr":{"nl":"Relatie","en":"Relation"}},"uri":"http:\/\/purl.org\/dc\/terms\/relation"}},"subject":{"objects":[{"created":"2026-09-09T13:48:08Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2575,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_navigation","title":"Navigation","uri":"https:\/\/zotonic.com\/id\/2575"},"seq":3},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2586,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_search_and_discovery","title":"Search and discovery","uri":"https:\/\/zotonic.com\/id\/2586"},"seq":4},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2623,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_scomp","title":"Server component","uri":"https:\/\/zotonic.com\/id\/2623"},"seq":5},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1396,"is_a":["text","documentation","reference","template_scomp"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1396"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_scomp_scomp_pager","page_url":{"en":"https:\/\/zotonic.com\/docs\/1396\/pager","x-default":"https:\/\/zotonic.com\/docs\/1396\/pager"},"preview_url":null,"resource":{"version":4022,"pivot_location_lat":null,"title":"pager","is_authoritative":true,"body":"<p>Show a pager for search results.<\/p>\n<p>This generates a pager as seen on the search results pages. It is used in conjunction with a paged search result.<\/p>\n<p>For example, a fulltext search where the search parameters come from the query string:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% with m.search.paged[{fulltext cat=q.qcat text=q.qs page=q.page pagelen=20}] as result %}\n  &lt;ul&gt;\n    {% pager result=result dispatch=&quot;admin_overview_rsc&quot; qargs %}\n    {% for id,score in result %}\n      &lt;li&gt;&lt;a href=&quot;&quot;&gt;{{ m.rsc[id].title }}&lt;\/a&gt;&lt;\/li&gt;\n    {% empty %}\n      &lt;li&gt;Nothing found&lt;\/li&gt;\n    {% endfor %}\n  &lt;\/ul&gt;\n{% endwith %}\n<\/code><\/pre>\n<p>This will show a list of titles and above that the links to the next, previous and other pages.<\/p>\n<div class=\"admonition note\"><p class=\"first admonition-title\">Note<\/p><p class=\"last\">that we are using <code>m.search.paged<\/code> here and not <a href=\"\/id\/doc_model_model_search\" class=\"doc-reference doc-reference-model\"><code>model#search<\/code><\/a>. The pager only works with\nresults from <code>m.search.paged<\/code>.<\/p><\/div>\n<p>The generated pager code will look something like (when searching for the text “filter”):<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;ul class=&quot;pager block&quot;&gt;\n&lt;li&gt;« prev&lt;\/li&gt;\n&lt;li class=&quot;current&quot;&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=1&quot;&gt;1&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=2&quot;&gt;2&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=3&quot;&gt;3&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=4&quot;&gt;4&lt;\/a&gt;&lt;\/li&gt;\n&lt;li class=&quot;pager-sep&quot;&gt;…&lt;\/li&gt;\n&lt;li&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=5&quot;&gt;5&lt;\/a&gt;&lt;\/li&gt;\n&lt;li&gt;&lt;a href=&quot;\/admin\/overview?qs=filter&amp;page=2&quot;&gt;next»&lt;\/a&gt;&lt;\/li&gt;\n&lt;\/ul&gt;\n<\/code><\/pre>\n<p>The pager tag accepts the following arguments:<\/p>\n<table class=\"table\"><thead><tr><th>Argument<\/th><th>Description<\/th><th>Example<\/th><\/tr><\/thead><tbody><tr><td><code>result<\/code><\/td><td>The result from a search. This must be a <code>#search_result<\/code> or a list. This mostly the result of a <code>m.search<\/code> call.<\/td><td><code>result=mysearchresult<\/code><\/td><\/tr><tr><td><code>dispatch<\/code><\/td><td>Name of the dispatch rule to be used for the page urls. Defaults to the dispatch rule of the current page. If there is no dispatch rule defined then <code>none<\/code> is used and only a link with the query arguments is generated. For example <code>?page=2&amp;qs=test<\/code><\/td><td><code>dispatch=&quot;searchresult&quot;<\/code><\/td><\/tr><tr><td><code>qargs<\/code><\/td><td>Append all the arguments in the HTTP request’s query string whose name starts with a ‘q’ as an argument to the dispatch rule.<\/td><td><code>qargs<\/code><\/td><\/tr><tr><td><code>hash<\/code><\/td><td>Hash to append to the pagination links. Used to jump to the search results on the load of a new page.<\/td><td><code>hash=”#content-pager”<\/code><\/td><\/tr><tr><td><code>hide_single_page<\/code><\/td><td>When this argument is true, do not show the pager when the result fits on one page (e.g. the pager will be useless).<\/td><td><code>hide_single_page=1<\/code><\/td><\/tr><tr><td><code>template<\/code><\/td><td>Name of the template for rendering the pager. Defaults to <code>_pager.tpl<\/code>. See below for specific arguments passed.<\/td><td><code>template=&quot;_pager.tpl&quot;<\/code><\/td><\/tr><tr><td><code>page<\/code><\/td><td>Current page number, the first page is page number 1. Fetched from the search result, this argument, or <code>q.page<\/code>.<\/td><td><code>page=2<\/code><\/td><\/tr><tr><td><code>pagelen<\/code><\/td><td>Number of items per page, fetch from the search result or <code>q.pagelen<\/code>. Defaults to 20.<\/td><td><code>pagelen=10<\/code><\/td><\/tr><tr><td><code>topic<\/code><\/td><td>The topic for handling the link clicks. Normally a link click will just load a new page in the browser. This intercepts the click and sends the new link to the given topic.<\/td><td><code>topic=”\/model\/location\/post\/push”<\/code><\/td><\/tr><tr><td><code>*<\/code><\/td><td>Any other argument is used as an argument for the dispatch rule.<\/td><td><\/td><\/tr><\/tbody><\/table>\n<h2>Pager template<\/h2>\n<p>The pager is rendered using a template. The default template for the pager is <code>_pager.tpl<\/code>.<\/p>\n<p>The pager template receives the following variables:<\/p>\n<ul><li><code>prev_url<\/code> The url to the previous page, <code>undefined<\/code> if at first page.<\/li><li><code>next_url<\/code> The url to the next page, <code>undefined<\/code> if at last page.<\/li><li><code>pages<\/code> A list of tuples. Either <code>{PageNumber, Url}<\/code> or <code>{undefined, sep}<\/code> (<em>sep<\/em> is an atom).<\/li><li><code>page<\/code> The current page number<\/li><li>All other arguments passed to the scomp (<strong>attention:<\/strong> these are also used as dispatch arguments)<\/li><\/ul>\n<p>The default <code>_pager.tpl<\/code> displays an ellipsis for the <code>sep<\/code> entry.<\/p>\n<p>If the result set is empty then the template is not rendered. The template is also not rendered if there is a single\npage <em>and<\/em> <code>hide_single_page<\/code> is set.<\/p>\n<h2>Result argument<\/h2>\n<p>It is also possible to pass a list, a <code>#rsc_list{ list=Ids }<\/code> record, or a list of lists (pages) for the resut. In this\ncase you need to perform the pagination for displaying the results yourself. You can use the\n<a href=\"\/id\/doc_template_filter_filter_chunk\" class=\"doc-reference doc-reference-filter\"><code>filter#chunk<\/code><\/a> for this. The pager scomp will fetch the <code>page<\/code> and <code>pagelen<\/code> from the\npager arguments, or from the query arguments (if any). If the list is pre-chunked then the pages does not need the\n<code>pagelen<\/code> argument.<\/p>\n<h2>Topic<\/h2>\n<p>If the search result is refreshed on the page without a page reload, then the <code>topic<\/code> should be passed. This is the\ntopic that directly or indirectly triggers a refresh of the element displaying the search result.<\/p>\n<p>For example, you can make a live search:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">{% live topic=&quot;model\/location\/event\/qlist&quot;\n        template=&quot;_search.tpl&quot;\n        method=&quot;patch&quot;\n%}\n<\/code><\/pre>\n<p>With a <code>_search.tpl<\/code> template like this:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;form data-onsubmit-topic=&quot;model\/location\/post\/qlist\/submit&quot;\n      data-oninput-topic=&quot;model\/location\/post\/qlist\/submit&quot;\n      method=&quot;GET&quot;\n&gt;\n    &lt;input type=&quot;text&quot; name=&quot;qs&quot; value=&quot;{{ q.qs|escape }}&quot;&gt;\n&lt;\/form&gt;\n\n{% with m.search.query::%{ qargs: true, page: q.page } as result %}\n  &lt;ul&gt;\n    {% for id in result %}\n      &lt;a href=&quot;{{ id.page_url }}&quot;&gt;{{ id.title }}&lt;\/a&gt;\n    {% endfor %}\n  &lt;\/ul&gt;\n  {% pager result=result topic=&quot;model\/location\/post\/push&quot; qargs %}\n{% endwith %}\n<\/code><\/pre>\n<p>Typing in the search will automatically update the search result without reloading the page, as will a click on one of\nthe pager links.<\/p>","slug":"pager","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"2258bf77acc472a0df8ec47011fc8f1d77e778eb6fad4ba89cdbf3b8d58fc25b","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":327,"is_a":["meta","category"],"name":"template_scomp","title":"Scomp","uri":"https:\/\/zotonic.com\/id\/template_scomp"},"doc_source_path":"apps\/zotonic_mod_base\/src\/scomps\/scomp_base_pager.erl","publication_start":"2023-06-24T08:17:54Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_mod_base\/src\/scomps\/scomp_base_pager.erl","pivot_location_lng":null,"doc_source_kind":"scomp","name":"doc_template_scomp_scomp_pager","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:20Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_mod_base","publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"19073459ea19a1407318a37747716c6f8546ed23\n","erlang_module":"scomp_base_pager","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-07T21:20:17Z","title_slug":"pager"},"uri":"https:\/\/zotonic.com\/id\/1396","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1396"}},"status":"ok"}